Skip to content

Conversation

@BruceDai
Copy link
Contributor

@fdwr @huningxin PTAL, thanks.

Copy link

@fdwr fdwr left a 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);
Copy link

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.

Copy link
Contributor Author

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.

Copy link

@fdwr fdwr Apr 20, 2023

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

@BruceDai
Copy link
Contributor Author

@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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: needPadding?

@BruceDai
Copy link
Contributor Author

@huningxin Thanks for your reviewing.
I've updated commit to address your comments, please take another look, thanks.

Copy link
Contributor

@huningxin huningxin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@huningxin huningxin merged commit bb72a02 into webmachinelearning:main Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants