Skip to content
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

[wasm] Add ResizeBilinearGrad and ResizeNearestNeighborGrad kernels #7346

Merged
merged 8 commits into from
Feb 7, 2023

Conversation

chunnienc
Copy link
Collaborator

@chunnienc chunnienc commented Feb 6, 2023

@mattsoulanille and reviewers: This compiler explorer example https://godbolt.org/z/zGr56TWeT shows that the shape (helper) class and lambda argument are zero-cost in our usage as we discussed. You can see that the generated assembly codes for Operator1 (with these features) and Operator2 (native implementation) are the same.

To see the logs from the Cloud Build CI, please join either our discussion or announcement mailing list.


This change is Reviewable

@chunnienc chunnienc marked this pull request as ready for review February 6, 2023 19:21
Copy link
Member

@mattsoulanille mattsoulanille left a comment

Choose a reason for hiding this comment

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

LGTM. The shape abstraction makes indexing much easier to read!

Copy link
Collaborator

@pyu10055 pyu10055 left a comment

Choose a reason for hiding this comment

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

Thank you, nice Shape class.

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @chunnienc)


tfjs-backend-wasm/src/cc/shape.h line 57 at r1 (raw file):

  }

  inline T& operator[](size_t i) { return data_[i]; }

boundary check on i?

@chunnienc
Copy link
Collaborator Author

Thank you, nice Shape class.

Reviewable status: :shipit: complete! 2 of 1 approvals obtained (waiting on @chunnienc)

tfjs-backend-wasm/src/cc/shape.h line 57 at r1 (raw file):

  }

  inline T& operator[](size_t i) { return data_[i]; }

boundary check on i?

The operator[] does not do boundary checking, while the .at(i) method checks the boundary and can throw an std::out_of_range error. This is a convention in C++ STL and almost all containers (std::vector, std::array, etc) implement this behavior. That's also why I expose two methods for different use cases.
Ref:
https://en.cppreference.com/w/cpp/container/array/operator_at
https://en.cppreference.com/w/cpp/container/array/at

@chunnienc chunnienc merged commit 3b5bd71 into tensorflow:master Feb 7, 2023
@chunnienc chunnienc deleted the wasm-shape branch February 7, 2023 19:49
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