[Runtime] ShapeTuple.Product and ShapeTuple Printing#15652
Merged
tqchen merged 1 commit intoapache:unityfrom Sep 2, 2023
Merged
[Runtime] ShapeTuple.Product and ShapeTuple Printing#15652tqchen merged 1 commit intoapache:unityfrom
tqchen merged 1 commit intoapache:unityfrom
Conversation
8e25ad0 to
ce99f01
Compare
junrushao
added a commit
to junrushao/tvm
that referenced
this pull request
Sep 1, 2023
) This commit adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type Sh)apeTupleObj::Numel() const; // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ```
ce99f01 to
d43c852
Compare
Member
Author
|
CC: @tqchen |
junrushao
added a commit
to junrushao/tvm
that referenced
this pull request
Sep 1, 2023
) This commit adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type ShapeTupleObj::Numel() const; // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ```
tqchen
reviewed
Sep 1, 2023
| uint64_t size; | ||
|
|
||
| /*! \brief Get number of elements in the shape */ | ||
| index_type Numel() const; |
Member
There was a problem hiding this comment.
trying to dig a bit about related APIs. How about Product? the product of the shape values
Member
Author
There was a problem hiding this comment.
Both torch and matlab uses “numel”, and numpy uses “size” but we have already used this word for a different meaning
Member
There was a problem hiding this comment.
numel makes sense for an array api. e.g. array.numel. Just not sure if it is right to use it for shape.
Member
Author
There was a problem hiding this comment.
How about NumElements()?
Member
Author
There was a problem hiding this comment.
OK. I don't have strong opinion to use Product. It's just numel is a well-known convention, but Product is a newly-invented word with ambiguity, but I don't have strong opinion.
This PR adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type ShapeTupleObj::Product(); // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ```
d43c852 to
50fd5f7
Compare
junrushao
added a commit
to junrushao/tvm
that referenced
this pull request
Sep 2, 2023
This PR adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type ShapeTupleObj::Product(); // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ```
junrushao
added a commit
to junrushao/tvm
that referenced
this pull request
Sep 2, 2023
This PR adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type ShapeTupleObj::Product(); // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ```
junrushao
added a commit
to junrushao/tvm
that referenced
this pull request
Sep 2, 2023
This PR adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type ShapeTupleObj::Product(); // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ```
tqchen
approved these changes
Sep 2, 2023
tqchen
pushed a commit
that referenced
this pull request
Sep 2, 2023
* [Runtime] ShapeTuple.Product and ShapeTuple Printing (#15652) This PR adds two convenient methods for `ShapeTuple`. ```C++ // Returns the number of elements in the shape, // i.e. the product of all dimensions ShapeTupleObj::index_type ShapeTupleObj::Product(); // Printing method for shape std::ostream& operator<<(std::ostream& os, const ShapeTuple& shape); ``` * [Disco] Add `Scatter-From-Worker0` This PR introduces an API: ```C++ void ScatterFromWorker0(Optional<NDArray> send, NDArray recv); ``` This mimics the MPI-style scattering primitive that divides NDArray `send` into chunks, and send them to each worker's NDArray `recv`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two convenient methods for
ShapeTuple.