Skip to content

Conversation

@wanghaoshuang
Copy link
Contributor

@wanghaoshuang wanghaoshuang commented May 30, 2018

@wanghaoshuang wanghaoshuang requested review from kuke and qingqing01 May 31, 2018 00:35
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].
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

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

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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
...

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if rank > 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor

@qingqing01 qingqing01 left a comment

Choose a reason for hiding this comment

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

LGTM.

@wanghaoshuang wanghaoshuang merged commit adc0908 into PaddlePaddle:develop Jun 11, 2018
@tonyyang-svail
Copy link

Will there be a slice_grad_op?

@wanghaoshuang
Copy link
Contributor Author

@tonyyang-svail slice op is now used to slice tensor's shape whose gradient is not computed. But maybe it is necessary for some other scene.

@wanghaoshuang wanghaoshuang deleted the slice branch May 20, 2022 03:59
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.

4 participants