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

Move slice to phi #40736

Merged
merged 40 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
13f4409
move slice to pten
phlrain Feb 16, 2022
75aca6d
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 16, 2022
87099d1
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 17, 2022
8cecc9b
merge develop; test=develop
phlrain Feb 17, 2022
38cf61e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Feb 17, 2022
d02df1e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 1, 2022
fc7c39f
fix slice bug;
phlrain Mar 2, 2022
263b477
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 8, 2022
4d42f4f
update
phlrain Mar 10, 2022
d35f588
update
phlrain Mar 10, 2022
586671e
fix error
phlrain Mar 11, 2022
fe3d90b
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 11, 2022
ff98fbe
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 19, 2022
e8612cd
update
phlrain Mar 19, 2022
6c5cdee
fix bug
phlrain Mar 19, 2022
fc273bf
Merge branch 'develop' into move_slice_to_pten
phlrain Mar 19, 2022
e0d0d55
Merge branch 'move_slice_to_pten' of https://github.com/PaddlePaddle/…
phlrain Mar 20, 2022
bb3e4ea
polish code
phlrain Mar 20, 2022
bd45fbd
polish code
phlrain Mar 20, 2022
09aecc6
polish code
phlrain Mar 22, 2022
ed689cd
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 22, 2022
561169b
try to fix windows bug
phlrain Mar 22, 2022
d81fccc
add gpu compile flag;
phlrain Mar 22, 2022
e6f7982
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 22, 2022
3982a2a
try to fix
phlrain Mar 22, 2022
cbf1c0b
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 22, 2022
d059bf9
remov template;
phlrain Mar 23, 2022
9f8772b
polish code;
phlrain Mar 23, 2022
0e6adec
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 23, 2022
823a557
fix npu bug;
phlrain Mar 23, 2022
b4ff4d9
fix npu bug
phlrain Mar 24, 2022
d22990c
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 24, 2022
6f3623a
fix npu bug; test=develop
phlrain Mar 24, 2022
de07c26
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 24, 2022
f6313f8
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 24, 2022
75e4d69
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 25, 2022
8eaef69
fix slice bug;
phlrain Mar 25, 2022
66ebde2
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 25, 2022
922c93e
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
phlrain Mar 25, 2022
2bc1010
remove no need dep
phlrain Mar 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions paddle/fluid/operators/lu_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ void SetValueCompute(const framework::ExecutionContext& ctx,
auto dtype = framework::TransToProtoVarType(in->dtype());

auto in_dims = in->dims();
CheckAndUpdateSliceAttrs<int64_t>(in_dims, axes, starts, ends, &steps);
auto slice_dims = GetSliceDims(in_dims, axes, *starts, *ends, &steps);
auto decrease_slice_dims = GetDecreasedDims(slice_dims, decrease_axes);
phi::funcs::CheckAndUpdateSliceAttrs<int64_t>(in_dims, axes, starts, ends,
&steps);
auto slice_dims =
phi::funcs::GetSliceDims(in_dims, axes, *starts, *ends, &steps);
auto decrease_slice_dims =
phi::funcs::GetDecreasedDims(slice_dims, decrease_axes);

auto slice_dims_for_assign = decrease_slice_dims;
if (!none_axes.empty()) {
Expand Down Expand Up @@ -282,10 +285,10 @@ void SliceCompute(const framework::ExecutionContext& ctx,
}
}

CheckAndUpdateSliceAttrs(in_dims, axes, &starts, &ends);
slice_dims =
GetSliceDims<int64_t>(in_dims, axes, starts, ends, nullptr, nullptr);
out_dims = GetDecreasedDims(slice_dims, decrease_axis);
phi::funcs::CheckAndUpdateSliceAttrs(in_dims, axes, &starts, &ends);
slice_dims = phi::funcs::GetSliceDims<int64_t>(in_dims, axes, starts, ends,
nullptr, nullptr);
out_dims = phi::funcs::GetDecreasedDims(slice_dims, decrease_axis);

// 2.2 Get output
auto offsets = Eigen::DSizes<Eigen::DenseIndex, D>();
Expand Down
5 changes: 4 additions & 1 deletion paddle/fluid/operators/set_value_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/tensor_util.h"
#include "paddle/fluid/operators/assign_value_op.h"
#include "paddle/fluid/operators/slice_utils.h"
#include "paddle/fluid/operators/eigen/eigen_function.h"
#include "paddle/fluid/operators/elementwise/elementwise_op_function.h"
#include "paddle/fluid/operators/strided_slice_op.h"
#include "paddle/fluid/operators/utils.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/phi/kernels/funcs/slice_utils.h"

namespace paddle {
namespace operators {
Expand Down
10 changes: 7 additions & 3 deletions paddle/fluid/operators/set_value_op_npu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ limitations under the License. */
#include "paddle/fluid/operators/set_value_op.h"
#include "paddle/fluid/platform/device/npu/npu_op_runner.h"

#include "paddle/phi/kernels/funcs/slice_utils.h"

namespace paddle {
namespace operators {

Expand Down Expand Up @@ -51,9 +53,11 @@ class SetValueNPUKernel : public framework::OpKernel<T> {
}

auto in_dims = in->dims();
CheckAndUpdateSliceAttrs(in_dims, axes, &starts, &ends, &steps);
auto slice_dims = GetSliceDims(in_dims, axes, starts, ends, &steps);
auto decrease_slice_dims = GetDecreasedDims(slice_dims, decrease_axes);
phi::funcs::CheckAndUpdateSliceAttrs(in_dims, axes, &starts, &ends, &steps);
auto slice_dims =
phi::funcs::GetSliceDims(in_dims, axes, starts, ends, &steps);
auto decrease_slice_dims =
phi::funcs::GetDecreasedDims(slice_dims, decrease_axes);

auto slice_dims_for_assign = decrease_slice_dims;
if (!none_axes.empty()) {
Expand Down
15 changes: 9 additions & 6 deletions paddle/fluid/operators/slice_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License. */
#include <memory>
#include <string>
#include <vector>
#include "paddle/phi/kernels/funcs/slice_utils.h"

namespace paddle {
namespace operators {
Expand Down Expand Up @@ -101,15 +102,17 @@ class SliceOp : public framework::OperatorWithKernel {
"The size of ends must be equal to the size of axes."));
}

CheckAndUpdateSliceAttrs<int>(in_dims, axes, &starts, &ends, nullptr,
&infer_flags);
phi::funcs::CheckAndUpdateSliceAttrs<int>(in_dims, axes, &starts, &ends,
nullptr, &infer_flags);

auto slice_dims =
GetSliceDims<int>(in_dims, axes, starts, ends, nullptr, &infer_flags);
auto slice_dims = phi::funcs::GetSliceDims<int>(in_dims, axes, starts, ends,
nullptr, &infer_flags);
if (ctx->IsRuntime()) {
out_dims = GetDecreasedDims<int>(slice_dims, decrease_axis, &infer_flags);
out_dims = phi::funcs::GetDecreasedDims<int>(slice_dims, decrease_axis,
&infer_flags);
} else {
out_dims = GetDecreasedDims<int>(slice_dims, decrease_axis, nullptr);
out_dims =
phi::funcs::GetDecreasedDims<int>(slice_dims, decrease_axis, nullptr);
}

ctx->SetOutputDim("Out", out_dims);
Expand Down
Loading