未验证 提交 9c51eee1 编写于 作者: F From00 提交者: GitHub

Move Abs InferShape to phi (#39762)

* Move Abs InferShaper to phi

* Fix CI error
上级 6aafb2fa
...@@ -16,7 +16,10 @@ ...@@ -16,7 +16,10 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/unary.h"
#ifdef PADDLE_WITH_MKLDNN #ifdef PADDLE_WITH_MKLDNN
#include "paddle/fluid/platform/mkldnn_helper.h" #include "paddle/fluid/platform/mkldnn_helper.h"
#endif #endif
...@@ -27,16 +30,6 @@ namespace operators { ...@@ -27,16 +30,6 @@ namespace operators {
class AbsOp : public framework::OperatorWithKernel { class AbsOp : public framework::OperatorWithKernel {
public: public:
using framework::OperatorWithKernel::OperatorWithKernel; using framework::OperatorWithKernel::OperatorWithKernel;
void InferShape(framework::InferShapeContext* ctx) const override {
OP_INOUT_CHECK(ctx->HasInput("X"), "Input", "X", "abs");
OP_INOUT_CHECK(ctx->HasOutput("Out"), "Output", "Out", "abs");
auto in_dims = ctx->GetInputDim("X");
ctx->SetOutputDim("Out", in_dims);
ctx->ShareLoD("X", /*->*/ "Out");
}
}; };
class AbsOpMaker : public framework::OpProtoAndCheckerMaker { class AbsOpMaker : public framework::OpProtoAndCheckerMaker {
...@@ -148,11 +141,15 @@ class AbsDoubleGradOp : public framework::OperatorWithKernel { ...@@ -148,11 +141,15 @@ class AbsDoubleGradOp : public framework::OperatorWithKernel {
} // namespace operators } // namespace operators
} // namespace paddle } // namespace paddle
DELCARE_INFER_SHAPE_FUNCTOR(abs, AbsInferShapeFunctor,
PT_INFER_META(phi::UnchangedInferMeta));
namespace ops = paddle::operators; namespace ops = paddle::operators;
REGISTER_OPERATOR(abs, ops::AbsOp, ops::AbsOpMaker, REGISTER_OPERATOR(abs, ops::AbsOp, ops::AbsOpMaker,
ops::AbsGradMaker<paddle::framework::OpDesc>, ops::AbsGradMaker<paddle::framework::OpDesc>,
ops::AbsGradMaker<paddle::imperative::OpBase>); ops::AbsGradMaker<paddle::imperative::OpBase>,
AbsInferShapeFunctor);
REGISTER_OPERATOR(abs_grad, ops::AbsGradOp, REGISTER_OPERATOR(abs_grad, ops::AbsGradOp,
ops::AbsDoubleGradMaker<paddle::framework::OpDesc>, ops::AbsDoubleGradMaker<paddle::framework::OpDesc>,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册