-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
Could you make sure the behavior is exactly the same with numpy for the same configuration? |
Changed the behavior to match numpy: A single multi index is given by a column of the matrix (not by a row). @piiswrong is that what you recommended in your comments? |
DType *unravelled, DType *ravelled) { | ||
index_t idx(ravelled[i]); | ||
#pragma unroll | ||
for (int j = ndim; j--; ) { |
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 find this style a little confusing and would prefer for(int j = ndim; j >= 0; j--)
. What is the motivation ?
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.
Just a style issue. I have seen people using either variant.
08485cf
to
749d8e8
Compare
Is this ready to merge? We have an important use case for these ops and would like to test them soon. |
Ready from my point of view. |
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.
otherwise LGTM
src/operator/tensor/ravel.cc
Outdated
.set_attr<FResourceRequest>("FResourceRequest", [](const NodeAttrs& attrs) | ||
{ return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; }) | ||
.set_attr<nnvm::FListInputNames>("FListInputNames", [](const NodeAttrs& attrs) | ||
{ return std::vector<std::string>{"A"}; } ) |
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.
data
src/operator/tensor/ravel.cc
Outdated
.set_attr<FResourceRequest>("FResourceRequest", [](const NodeAttrs& attrs) | ||
{ return std::vector<ResourceRequest>{ResourceRequest::kTempSpace}; }) | ||
.set_attr<nnvm::FListInputNames>("FListInputNames", [](const NodeAttrs& attrs) | ||
{ return std::vector<std::string>{"A"}; } ) |
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.
data
src/operator/tensor/ravel.cc
Outdated
.set_attr<nnvm::FInferType>("FInferType", ElemwiseType<1, 1>) | ||
.set_attr<FCompute>("FCompute<cpu>", RavelForward<cpu>) | ||
.set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes) | ||
.add_argument("A", "NDArray-or-Symbol", "Batch of multi-indices") |
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.
data
src/operator/tensor/ravel.cc
Outdated
.set_attr<nnvm::FInferType>("FInferType", ElemwiseType<1, 1>) | ||
.set_attr<FCompute>("FCompute<cpu>", UnravelForward<cpu>) | ||
.set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes) | ||
.add_argument("A", "NDArray-or-Symbol", "Array of flat indices") |
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.
data
fe3a77c
to
f9b9b13
Compare
Changed input names from "A" to "data" as requested. |
Description
This resolves #10203 by implementing ravel_multi_index and unravel_index operators. The operators perform the same functionality as the corresponding operators in numpy.
This enables writing fully symbolic operations that involve ravel/unravel of indices.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.