-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add slice op. #11052
Add slice op. #11052
Conversation
paddle/fluid/operators/slice_op.cc
Outdated
elements before the end of that dimension. If the value passed to start or end is larger | ||
than the n (the number of elements in this dimension), it represents n. For slicing to the | ||
end of a dimension with unknown size, it is recommended to pass in INT_MAX. If axes are omitted, | ||
they are set to [0, ..., ndim-1]. |
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.
Each line should not be more than 80 characters. Please fix the lines above.
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.
Fixed.
paddle/fluid/operators/slice_op.h
Outdated
using Tensor = framework::Tensor; | ||
template <typename T, size_t D, int MajorType = Eigen::RowMajor, | ||
typename IndexType = Eigen::DenseIndex> | ||
using EigenTensor = framework::EigenTensor<T, D, MajorType, IndexType>; |
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.
Do not use using
in the header file.
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.
Fixed.
AddComment(R"DOC( | ||
Slice Operator. | ||
|
||
Produces a slice of the input tensor along multiple axes. Similar to numpy: |
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.
Seems that there are some typos in onnx doc, please correct them:
Slices --> Slice
axes, starts and ends --> axes
, starts
and ends
represent --> represents
...
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.
Fixed.
public: | ||
void Compute(const framework::ExecutionContext& ctx) const override { | ||
int rank = ctx.Input<framework::Tensor>("Input")->dims().size(); | ||
switch (rank) { |
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.
What if rank > 6?
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.
Fixed.
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.
Will there be a slice_grad_op? |
@tonyyang-svail |
https://github.com/onnx/onnx/blob/master/docs/Operators.md#slice