diff --git a/paddle/fluid/operators/shape_op.cc b/paddle/fluid/operators/shape_op.cc deleted file mode 100644 index 24d2f1104db5a949eb2a24f2d23ae562ab1fb21e..0000000000000000000000000000000000000000 --- a/paddle/fluid/operators/shape_op.cc +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -#include - -#include "paddle/fluid/framework/infershape_utils.h" -#include "paddle/fluid/framework/op_registry.h" -#include "paddle/phi/core/infermeta_utils.h" -#include "paddle/phi/infermeta/unary.h" - -namespace paddle { -namespace operators { - -class ShapeOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext &ctx) const override { - auto input_data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - return phi::KernelKey(input_data_type, ctx.GetPlace()); - } - - protected: - phi::KernelKey GetKernelTypeForVar( - const std::string &var_name, - const phi::DenseTensor &tensor, - const phi::KernelKey &expected_kernel_type) const override { - return phi::KernelKey(phi::Backend::ALL_BACKEND, - tensor.layout(), - expected_kernel_type.dtype()); - } -}; - -class ShapeOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(phi::DenseTensor), The input tensor."); - AddOutput("Out", - "(phi::DenseTensor), The shape of input tensor, the data type of " - "the shape" - " is int32_t, will be on the same device with the input Tensor."); - AddComment(R"DOC( -Shape Operator. - -Return the shape of the input. -)DOC"); - } -}; - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(ShapeNoNeedBufferVarsInferer, "Input"); - -} // namespace operators -} // namespace paddle - -namespace ops = paddle::operators; -namespace plat = paddle::platform; - -DECLARE_INFER_SHAPE_FUNCTOR(shape, - ShapeInferShapeFunctor, - PD_INFER_META(phi::ShapeInferMeta)); - -REGISTER_OPERATOR( - shape, - ops::ShapeOp, - ops::ShapeOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ShapeNoNeedBufferVarsInferer, - ShapeInferShapeFunctor); diff --git a/paddle/phi/api/yaml/legacy_ops.yaml b/paddle/phi/api/yaml/legacy_ops.yaml index 50158c513fda5926b86f3c2c3902685a38daf483..532e445a1a7821813631443b6b1ed6802a80140d 100755 --- a/paddle/phi/api/yaml/legacy_ops.yaml +++ b/paddle/phi/api/yaml/legacy_ops.yaml @@ -903,17 +903,6 @@ intermediate : noise backward : rrelu_grad -- op : shape - args : (Tensor input) - output : Tensor(out) - infer_meta : - func : ShapeInferMeta - kernel : - func : shape {dense -> dense}, - shape_sr {selected_rows -> selected_rows} - data_transform: - skip_transform : input - - op : slice args : (Tensor input, int64_t[] axes, IntArray starts, IntArray ends, int64_t[] infer_flags, int64_t[] decrease_axis) output : Tensor diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index 7a46548d8661936b75eebf700c78f388cfaa9fa5..a860734f784e5e22e7face60b0fa0bedf33b03db 100755 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -2135,6 +2135,12 @@ extra : attrs : [bool use_mkldnn=false] +- op : shape + inputs : + input : Input + outputs : + out : Out + - op : shape extra : attrs : [bool use_mkldnn = false, str mkldnn_data_type = "float32"] diff --git a/paddle/phi/api/yaml/ops.yaml b/paddle/phi/api/yaml/ops.yaml index e247e3f3c6290adfd30ae86cdc4d63ed0c65b095..043527bbdef22a969a8d490cd6fc6978637a6cc6 100644 --- a/paddle/phi/api/yaml/ops.yaml +++ b/paddle/phi/api/yaml/ops.yaml @@ -1959,6 +1959,17 @@ optional : master_param, master_param_out inplace : (param -> param_out), (master_param -> master_param_out) +- op : shape + args : (Tensor input) + output : Tensor(out) + infer_meta : + func : ShapeInferMeta + kernel : + func : shape {dense -> dense}, + shape_sr {selected_rows -> selected_rows} + data_transform: + skip_transform : input + - op : shard_index args : (Tensor input, int index_num, int nshards, int shard_id, int ignore_value=-1) output : Tensor(out) diff --git a/paddle/phi/kernels/onednn/shape_kernel.cc b/paddle/phi/kernels/onednn/shape_kernel.cc index a59e8fa01daa537ea2430faa9cfa6f8d457f271f..51b35ae4a3c0c74ec79666a2e8af4a0e5062599d 100644 --- a/paddle/phi/kernels/onednn/shape_kernel.cc +++ b/paddle/phi/kernels/onednn/shape_kernel.cc @@ -56,4 +56,6 @@ PD_REGISTER_KERNEL(shape, float, phi::dtype::bfloat16, int8_t, - uint8_t) {} + uint8_t) { + kernel->InputAt(0).SetBackend(phi::Backend::ALL_BACKEND); +} diff --git a/test/cpp/fluid/mkldnn/CMakeLists.txt b/test/cpp/fluid/mkldnn/CMakeLists.txt index bf56915f06524883067c5a237d83d347eac6e168..c3621eaff0fce8bf8e41fa694a99b2aa9a0f090e 100644 --- a/test/cpp/fluid/mkldnn/CMakeLists.txt +++ b/test/cpp/fluid/mkldnn/CMakeLists.txt @@ -42,7 +42,6 @@ cc_test_old( recurrent_op op_registry pool_op - shape_op crop_op activation_op generated_op