-
Notifications
You must be signed in to change notification settings - Fork 8
Implement pad op #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement pad op #47
Conversation
fdwr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to stare at getMappedLocation some more tomorrow, but some partial feedback for now.
src/pad.js
Outdated
| const outputShape = input.shape.map((v, i) => v + beginningPadding[i] + endingPadding[i]); | ||
| let output = new Tensor(outputShape); | ||
| for (let i = 0; i < output.size; ++i) { | ||
| output = updateOutput(i, input, output, beginningPadding, mode, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct to overwrite output? Doesn't updateOutput already call setValueByIndex? Otherwise line 108 will only return the last loop value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this for loop is to set each element of output tensor by index.
Maybe the function name updateOutput confuse you, how about renaming it as updateElement or something, any suggestions? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I missed this notification, and the CR is already completed meaning it doesn't matter much now, but to answer your question)
Couldn't this:
for (let i = 0; i < output.size; ++i) {
output = updateOutput(i, input, output, beginningPadding, mode, value);
}
Have been this?...
for (let i = 0; i < output.size; ++i) {
updateOutput(i, input, output, beginningPadding, mode, value);
}
...since updateOutput is already calling setValueByIndex on the destination.
[update]
Thanks: #50
|
@fdwr Thanks for your review, I'll address these comments after your complete review. |
src/pad.js
Outdated
| const sourceShape = source.shape; | ||
| const location = destination.locationFromIndex(index); | ||
| const rank = location.length; | ||
| let hasFillPadding = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: needPadding?
|
@huningxin Thanks for your reviewing. |
huningxin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@fdwr @huningxin PTAL, thanks.