diff --git a/paddle/fluid/operators/generated_op.cc b/paddle/fluid/operators/generated_op.cc deleted file mode 100644 index 8b7a92a1f0ae5..0000000000000 --- a/paddle/fluid/operators/generated_op.cc +++ /dev/null @@ -1,9618 +0,0 @@ -// Copyright (c) 2023 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. - -// this file is generated by paddle/phi/api/yaml/generator/generate_op.py, do -// not edit. -#include -#include "paddle/fluid/framework/convert_utils.h" -#include "paddle/fluid/framework/infershape_utils.h" -#include "paddle/fluid/framework/op_registry.h" -#include "paddle/fluid/framework/op_version_registry.h" -#include "paddle/fluid/prim/api/manual/backward/composite_backward_api.h" -#include "paddle/fluid/prim/utils/static/composite_grad_desc_maker.h" -#include "paddle/fluid/prim/utils/static/desc_tensor.h" -#include "paddle/phi/core/infermeta_utils.h" -#include "paddle/phi/infermeta/backward.h" -#include "paddle/phi/infermeta/binary.h" -#include "paddle/phi/infermeta/multiary.h" -#include "paddle/phi/infermeta/nullary.h" -#include "paddle/phi/infermeta/ternary.h" -#include "paddle/phi/infermeta/unary.h" - -namespace paddle { -namespace operators { - -using paddle::framework::GradVarName; - -class TanhCompositeGradOpMaker : public prim::GradCompositeOpMakerBase { - public: - using prim::GradCompositeOpMakerBase::GradCompositeOpMakerBase; - - void Apply() override { - paddle::experimental::Tensor out = paddle::experimental::Tensor( - std::make_shared(this->SingleForwardOutput("Out"))); - paddle::experimental::Tensor grad_out = paddle::experimental::Tensor( - std::make_shared(this->SingleOutputGrad("Out"))); - paddle::experimental::Tensor grad_x = paddle::experimental::Tensor( - std::make_shared(this->SingleInputGrad("X"))); - prim::tanh_grad(out, grad_out, &grad_x); - } -}; - -class AcosOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of acos op."); - AddOutput("Out", "(Tensor), output 0 of acos op."); - AddComment(R"DOC( -TODO: Documentation of acos op. -)DOC"); - } -}; - -class AcosOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(acos, - AcosInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class AcoshOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of acosh op."); - AddOutput("Out", "(Tensor), output 0 of acosh op."); - AddComment(R"DOC( -TODO: Documentation of acosh op. -)DOC"); - } -}; - -class AcoshOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(acosh, - AcoshInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class AddmmOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of addmm op."); - AddInput("X", "(Tensor), input 1 of addmm op."); - AddInput("Y", "(Tensor), input 2 of addmm op."); - AddOutput("Out", "(Tensor), output 0 of addmm op."); - AddAttr("Beta", "(float), attribute 0 for addmm op.") - .SetDefault(1.0); - AddAttr("Alpha", "(float), attribute 1 for addmm op.") - .SetDefault(1.0); - AddComment(R"DOC( -TODO: Documentation of addmm op. -)DOC"); - } -}; - -class AddmmOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(addmm, - AddmmInferShapeFunctor, - PD_INFER_META(phi::AddmmInferMeta)); - -class AllcloseOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of allclose op."); - AddInput("Other", "(Tensor), input 1 of allclose op."); - AddOutput("Out", "(Tensor), output 0 of allclose op."); - AddInput("Rtol", "attribute 0 for allclose op from 0D Tensor.") - .AsDispensable(); - AddAttr("rtol", "(std::string), attribute 0 for allclose op.") - .SetDefault("1e-5"); - AddInput("Atol", "attribute 1 for allclose op from 0D Tensor.") - .AsDispensable(); - AddAttr("atol", "(std::string), attribute 1 for allclose op.") - .SetDefault("1e-8"); - AddAttr("equal_nan", "(bool), attribute 2 for allclose op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of allclose op. -)DOC"); - } -}; - -class AllcloseOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(allclose, - AllcloseInferShapeFunctor, - PD_INFER_META(phi::AllValueCompareInferMeta)); - -class AngleOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of angle op."); - AddOutput("Out", "(Tensor), output 0 of angle op."); - AddComment(R"DOC( -TODO: Documentation of angle op. -)DOC"); - } -}; - -class AngleOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(angle, - AngleInferShapeFunctor, - PD_INFER_META(phi::RealAndImagInferMeta)); - -class ArgsortOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of argsort op."); - AddOutput("Out", "(Tensor), output 0 of argsort op."); - AddOutput("Indices", "(Tensor), output 1 of argsort op."); - AddAttr("axis", "(int), attribute 0 for argsort op.").SetDefault(-1); - AddAttr("descending", "(bool), attribute 1 for argsort op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of argsort op. -)DOC"); - } -}; - -class ArgsortOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(argsort, - ArgsortInferShapeFunctor, - PD_INFER_META(phi::ArgsortInferMeta)); - -class AsComplexOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of as_complex op."); - AddOutput("Out", "(Tensor), output 0 of as_complex op."); - AddComment(R"DOC( -TODO: Documentation of as_complex op. -)DOC"); - } -}; - -class AsComplexOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(as_complex, - AsComplexInferShapeFunctor, - PD_INFER_META(phi::AsComplexInferMeta)); - -class AsRealOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of as_real op."); - AddOutput("Out", "(Tensor), output 0 of as_real op."); - AddComment(R"DOC( -TODO: Documentation of as_real op. -)DOC"); - } -}; - -class AsRealOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(as_real, - AsRealInferShapeFunctor, - PD_INFER_META(phi::AsRealInferMeta)); - -class AsinOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of asin op."); - AddOutput("Out", "(Tensor), output 0 of asin op."); - AddComment(R"DOC( -TODO: Documentation of asin op. -)DOC"); - } -}; - -class AsinOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(asin, - AsinInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class AsinhOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of asinh op."); - AddOutput("Out", "(Tensor), output 0 of asinh op."); - AddComment(R"DOC( -TODO: Documentation of asinh op. -)DOC"); - } -}; - -class AsinhOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(asinh, - AsinhInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class AtanOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of atan op."); - AddOutput("Out", "(Tensor), output 0 of atan op."); - AddComment(R"DOC( -TODO: Documentation of atan op. -)DOC"); - } -}; - -class AtanOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(atan, - AtanInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class Atan2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X1", "(Tensor), input 0 of atan2 op."); - AddInput("X2", "(Tensor), input 1 of atan2 op."); - AddOutput("Out", "(Tensor), output 0 of atan2 op."); - AddComment(R"DOC( -TODO: Documentation of atan2 op. -)DOC"); - } -}; - -class Atan2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(atan2, - Atan2InferShapeFunctor, - PD_INFER_META(phi::Atan2InferMeta)); - -class AtanhOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of atanh op."); - AddOutput("Out", "(Tensor), output 0 of atanh op."); - AddComment(R"DOC( -TODO: Documentation of atanh op. -)DOC"); - } -}; - -class AtanhOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(atanh, - AtanhInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class BernoulliOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of bernoulli op."); - AddOutput("Out", "(Tensor), output 0 of bernoulli op."); - AddComment(R"DOC( -TODO: Documentation of bernoulli op. -)DOC"); - } -}; - -class BernoulliOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(bernoulli, - BernoulliInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class BmmOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of bmm op."); - AddInput("Y", "(Tensor), input 1 of bmm op."); - AddOutput("Out", "(Tensor), output 0 of bmm op."); - AddComment(R"DOC( -TODO: Documentation of bmm op. -)DOC"); - } -}; - -class BmmOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(bmm, - BmmInferShapeFunctor, - PD_INFER_META(phi::BmmInferMeta)); - -class CeilOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of ceil op."); - AddOutput("Out", "(Tensor), output 0 of ceil op."); - AddComment(R"DOC( -TODO: Documentation of ceil op. -)DOC"); - } -}; - -class CeilOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(ceil, - CeilInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(CeilInplaceInferer, {"X", "Out"}); - -class CeluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of celu op."); - AddOutput("Out", "(Tensor), output 0 of celu op."); - AddAttr("alpha", "(float), attribute 0 for celu op.") - .SetDefault(1.0); - AddComment(R"DOC( -TODO: Documentation of celu op. -)DOC"); - } -}; - -class CeluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(celu, - CeluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class CholeskyOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of cholesky op."); - AddOutput("Out", "(Tensor), output 0 of cholesky op."); - AddAttr("upper", "(bool), attribute 0 for cholesky op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of cholesky op. -)DOC"); - } -}; - -class CholeskyOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cholesky, - CholeskyInferShapeFunctor, - PD_INFER_META(phi::CholeskyInferMeta)); - -class CholeskySolveOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of cholesky_solve op."); - AddInput("Y", "(Tensor), input 1 of cholesky_solve op."); - AddOutput("Out", "(Tensor), output 0 of cholesky_solve op."); - AddAttr("upper", "(bool), attribute 0 for cholesky_solve op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of cholesky_solve op. -)DOC"); - } -}; - -class CholeskySolveOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cholesky_solve, - CholeskySolveInferShapeFunctor, - PD_INFER_META(phi::CholeskySolveInferMeta)); - -class ClipOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of clip op."); - AddOutput("Out", "(Tensor), output 0 of clip op."); - AddInput("Min", "attribute 0 for clip op from 0D Tensor.").AsDispensable(); - AddAttr("min", "(float), attribute 0 for clip op."); - AddInput("Max", "attribute 1 for clip op from 0D Tensor.").AsDispensable(); - AddAttr("max", "(float), attribute 1 for clip op."); - AddComment(R"DOC( -TODO: Documentation of clip op. -)DOC"); - } -}; - -class ClipOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(clip, - ClipInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ClipInplaceInferer, {"X", "Out"}); - -class ComplexOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of complex op."); - AddInput("Y", "(Tensor), input 1 of complex op."); - AddOutput("Out", "(Tensor), output 0 of complex op."); - AddComment(R"DOC( -TODO: Documentation of complex op. -)DOC"); - } -}; - -class ComplexOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(complex, - ComplexInferShapeFunctor, - PD_INFER_META(phi::ComplexInferMeta)); - -class ConjOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of conj op."); - AddOutput("Out", "(Tensor), output 0 of conj op."); - AddComment(R"DOC( -TODO: Documentation of conj op. -)DOC"); - } -}; - -class ConjOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(conj, - ConjInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class CosOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of cos op."); - AddOutput("Out", "(Tensor), output 0 of cos op."); - AddComment(R"DOC( -TODO: Documentation of cos op. -)DOC"); - } -}; - -class CosOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cos, - CosInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class CoshOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of cosh op."); - AddOutput("Out", "(Tensor), output 0 of cosh op."); - AddComment(R"DOC( -TODO: Documentation of cosh op. -)DOC"); - } -}; - -class CoshOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cosh, - CoshInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class CropTensorOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of crop_tensor op."); - AddOutput("Out", "(Tensor), output 0 of crop_tensor op."); - AddInput("Shape", "attribute 0 for crop_tensor op from 1D integer Tensor.") - .AsDispensable(); - AddInput("ShapeTensor", - "attribute 0 for crop_tensor op from list fo 0D integer Tensors.") - .AsDuplicable() - .AsDispensable(); - AddAttr>( - "shape", "(std::vector), attribute 0 for crop_tensor op.") - .SetDefault({}); - AddInput("Offsets", - "attribute 1 for crop_tensor op from 1D integer Tensor.") - .AsDispensable(); - AddInput("OffsetsTensor", - "attribute 1 for crop_tensor op from list fo 0D integer Tensors.") - .AsDuplicable() - .AsDispensable(); - AddAttr>( - "offsets", "(std::vector), attribute 1 for crop_tensor op.") - .SetDefault({}); - AddComment(R"DOC( -TODO: Documentation of crop_tensor op. -)DOC"); - } -}; - -class CropTensorOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(crop_tensor, - CropTensorInferShapeFunctor, - PD_INFER_META(phi::CropInferMeta)); - -class CrossOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of cross op."); - AddInput("Y", "(Tensor), input 1 of cross op."); - AddOutput("Out", "(Tensor), output 0 of cross op."); - AddAttr("dim", "(int), attribute 0 for cross op.").SetDefault(9); - AddComment(R"DOC( -TODO: Documentation of cross op. -)DOC"); - } -}; - -class CrossOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cross, - CrossInferShapeFunctor, - PD_INFER_META(phi::CrossInferMeta)); - -class DeterminantOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of determinant op."); - AddOutput("Out", "(Tensor), output 0 of determinant op."); - AddComment(R"DOC( -TODO: Documentation of determinant op. -)DOC"); - } -}; - -class DeterminantOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(determinant, - DeterminantInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class DiagV2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of diag_v2 op."); - AddOutput("Out", "(Tensor), output 0 of diag_v2 op."); - AddAttr("offset", "(int), attribute 0 for diag_v2 op.").SetDefault(0); - AddAttr("padding_value", "(float), attribute 1 for diag_v2 op.") - .SetDefault(0.0); - AddComment(R"DOC( -TODO: Documentation of diag_v2 op. -)DOC"); - } -}; - -class DiagV2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(diag_v2, - DiagV2InferShapeFunctor, - PD_INFER_META(phi::DiagInferMeta)); - -class DiagEmbedOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of diag_embed op."); - AddOutput("Out", "(Tensor), output 0 of diag_embed op."); - AddAttr("offset", "(int), attribute 0 for diag_embed op.") - .SetDefault(0); - AddAttr("dim1", "(int), attribute 1 for diag_embed op.") - .SetDefault(-2); - AddAttr("dim2", "(int), attribute 2 for diag_embed op.") - .SetDefault(-1); - AddComment(R"DOC( -TODO: Documentation of diag_embed op. -)DOC"); - } -}; - -class DiagEmbedOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(diag_embed, - DiagEmbedInferShapeFunctor, - PD_INFER_META(phi::DiagEmbedInferMeta)); - -class DiagonalOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of diagonal op."); - AddOutput("Out", "(Tensor), output 0 of diagonal op."); - AddAttr("offset", "(int), attribute 0 for diagonal op.").SetDefault(0); - AddAttr("axis1", "(int), attribute 1 for diagonal op.").SetDefault(0); - AddAttr("axis2", "(int), attribute 2 for diagonal op.").SetDefault(1); - AddComment(R"DOC( -TODO: Documentation of diagonal op. -)DOC"); - } -}; - -class DiagonalOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(diagonal, - DiagonalInferShapeFunctor, - PD_INFER_META(phi::DiagonalInferMeta)); - -class DigammaOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of digamma op."); - AddOutput("Out", "(Tensor), output 0 of digamma op."); - AddComment(R"DOC( -TODO: Documentation of digamma op. -)DOC"); - } -}; - -class DigammaOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(digamma, - DigammaInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class DistOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of dist op."); - AddInput("Y", "(Tensor), input 1 of dist op."); - AddOutput("Out", "(Tensor), output 0 of dist op."); - AddAttr("p", "(float), attribute 0 for dist op.").SetDefault(2.0); - AddComment(R"DOC( -TODO: Documentation of dist op. -)DOC"); - } -}; - -class DistOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(dist, - DistInferShapeFunctor, - PD_INFER_META(phi::DistInferMeta)); - -class DotOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of dot op."); - AddInput("Y", "(Tensor), input 1 of dot op."); - AddOutput("Out", "(Tensor), output 0 of dot op."); - AddComment(R"DOC( -TODO: Documentation of dot op. -)DOC"); - } -}; - -class DotOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(dot, - DotInferShapeFunctor, - PD_INFER_META(phi::DotInferMeta)); - -class EigOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of eig op."); - AddOutput("Eigenvalues", "(Tensor), output 0 of eig op."); - AddOutput("Eigenvectors", "(Tensor), output 1 of eig op."); - AddComment(R"DOC( -TODO: Documentation of eig op. -)DOC"); - } -}; - -class EigOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(eig, - EigInferShapeFunctor, - PD_INFER_META(phi::EigInferMeta)); - -class EighOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of eigh op."); - AddOutput("Eigenvalues", "(Tensor), output 0 of eigh op."); - AddOutput("Eigenvectors", "(Tensor), output 1 of eigh op."); - AddAttr("UPLO", "(std::string), attribute 0 for eigh op.") - .SetDefault("L"); - AddComment(R"DOC( -TODO: Documentation of eigh op. -)DOC"); - } -}; - -class EighOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(eigh, - EighInferShapeFunctor, - PD_INFER_META(phi::EighInferMeta)); - -class EigvalsOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of eigvals op."); - AddOutput("Out", "(Tensor), output 0 of eigvals op."); - AddComment(R"DOC( -TODO: Documentation of eigvals op. -)DOC"); - } -}; - -class EigvalsOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(eigvals, - EigvalsInferShapeFunctor, - PD_INFER_META(phi::EigvalsInferMeta)); - -class EluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of elu op."); - AddOutput("Out", "(Tensor), output 0 of elu op."); - AddAttr("alpha", "(float), attribute 0 for elu op.") - .SetDefault(1.0f); - AddComment(R"DOC( -TODO: Documentation of elu op. -)DOC"); - } -}; - -class EluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(elu, - EluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(EluInplaceInferer, {"X", "Out"}); - -class EqualAllOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of equal_all op."); - AddInput("Y", "(Tensor), input 1 of equal_all op."); - AddOutput("Out", "(Tensor), output 0 of equal_all op."); - AddComment(R"DOC( -TODO: Documentation of equal_all op. -)DOC"); - } -}; - -class EqualAllOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(equal_all, - EqualAllInferShapeFunctor, - PD_INFER_META(phi::CompareAllInferMeta)); - -class ErfOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of erf op."); - AddOutput("Out", "(Tensor), output 0 of erf op."); - AddComment(R"DOC( -TODO: Documentation of erf op. -)DOC"); - } -}; - -class ErfOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(erf, - ErfInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class ErfinvOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of erfinv op."); - AddOutput("Out", "(Tensor), output 0 of erfinv op."); - AddComment(R"DOC( -TODO: Documentation of erfinv op. -)DOC"); - } -}; - -class ErfinvOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(erfinv, - ErfinvInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ErfinvInplaceInferer, {"X", "Out"}); - -class ExpOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of exp op."); - AddOutput("Out", "(Tensor), output 0 of exp op."); - AddComment(R"DOC( -TODO: Documentation of exp op. -)DOC"); - } -}; - -class ExpOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(exp, - ExpInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ExpInplaceInferer, {"X", "Out"}); - -class Expm1OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of expm1 op."); - AddOutput("Out", "(Tensor), output 0 of expm1 op."); - AddComment(R"DOC( -TODO: Documentation of expm1 op. -)DOC"); - } -}; - -class Expm1Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(expm1, - Expm1InferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class FftC2cOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of fft_c2c op."); - AddOutput("Out", "(Tensor), output 0 of fft_c2c op."); - AddAttr>( - "axes", "(std::vector), attribute 0 for fft_c2c op."); - AddAttr("normalization", - "(std::string), attribute 1 for fft_c2c op."); - AddAttr("forward", "(bool), attribute 2 for fft_c2c op."); - AddComment(R"DOC( -TODO: Documentation of fft_c2c op. -)DOC"); - } -}; - -class FftC2cOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fft_c2c, - FftC2cInferShapeFunctor, - PD_INFER_META(phi::FFTC2CInferMeta)); - -class FftC2rOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of fft_c2r op."); - AddOutput("Out", "(Tensor), output 0 of fft_c2r op."); - AddAttr>( - "axes", "(std::vector), attribute 0 for fft_c2r op."); - AddAttr("normalization", - "(std::string), attribute 1 for fft_c2r op."); - AddAttr("forward", "(bool), attribute 2 for fft_c2r op."); - AddAttr("last_dim_size", "(int64_t), attribute 3 for fft_c2r op.") - .SetDefault(0L); - AddComment(R"DOC( -TODO: Documentation of fft_c2r op. -)DOC"); - } -}; - -class FftC2rOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fft_c2r, - FftC2rInferShapeFunctor, - PD_INFER_META(phi::FFTC2RInferMeta)); - -class FftR2cOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of fft_r2c op."); - AddOutput("Out", "(Tensor), output 0 of fft_r2c op."); - AddAttr>( - "axes", "(std::vector), attribute 0 for fft_r2c op."); - AddAttr("normalization", - "(std::string), attribute 1 for fft_r2c op."); - AddAttr("forward", "(bool), attribute 2 for fft_r2c op."); - AddAttr("onesided", "(bool), attribute 3 for fft_r2c op."); - AddComment(R"DOC( -TODO: Documentation of fft_r2c op. -)DOC"); - } -}; - -class FftR2cOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fft_r2c, - FftR2cInferShapeFunctor, - PD_INFER_META(phi::FFTR2CInferMeta)); - -class FillDiagonalOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of fill_diagonal op."); - AddOutput("Out", "(Tensor), output 0 of fill_diagonal op."); - AddAttr("value", "(float), attribute 0 for fill_diagonal op.") - .SetDefault(0); - AddAttr("offset", "(int), attribute 1 for fill_diagonal op.") - .SetDefault(0); - AddAttr("wrap", "(bool), attribute 2 for fill_diagonal op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of fill_diagonal op. -)DOC"); - } -}; - -class FillDiagonalOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fill_diagonal, - FillDiagonalInferShapeFunctor, - PD_INFER_META(phi::FillDiagonalInferMeta)); -DECLARE_INPLACE_OP_INFERER(FillDiagonalInplaceInferer, {"X", "Out"}); - -class FillDiagonalTensorOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of fill_diagonal_tensor op."); - AddInput("Y", "(Tensor), input 1 of fill_diagonal_tensor op."); - AddOutput("Out", "(Tensor), output 0 of fill_diagonal_tensor op."); - AddAttr("offset", - "(int64_t), attribute 0 for fill_diagonal_tensor op.") - .SetDefault(0); - AddAttr("dim1", "(int), attribute 1 for fill_diagonal_tensor op.") - .SetDefault(0); - AddAttr("dim2", "(int), attribute 2 for fill_diagonal_tensor op.") - .SetDefault(1); - AddComment(R"DOC( -TODO: Documentation of fill_diagonal_tensor op. -)DOC"); - } -}; - -class FillDiagonalTensorOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fill_diagonal_tensor, - FillDiagonalTensorInferShapeFunctor, - PD_INFER_META(phi::FillDiagonalTensorInferMeta)); -DECLARE_INPLACE_OP_INFERER(FillDiagonalTensorInplaceInferer, {"X", "Out"}); - -class FlipOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of flip op."); - AddOutput("Out", "(Tensor), output 0 of flip op."); - AddAttr>("axis", - "(std::vector), attribute 0 for flip op."); - AddComment(R"DOC( -TODO: Documentation of flip op. -)DOC"); - } -}; - -class FlipOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(flip, - FlipInferShapeFunctor, - PD_INFER_META(phi::FlipInferMeta)); - -class FloorOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of floor op."); - AddOutput("Out", "(Tensor), output 0 of floor op."); - AddComment(R"DOC( -TODO: Documentation of floor op. -)DOC"); - } -}; - -class FloorOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(floor, - FloorInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(FloorInplaceInferer, {"X", "Out"}); - -class FoldOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of fold op."); - AddOutput("Y", "(Tensor), output 0 of fold op."); - AddAttr>("output_sizes", - "(std::vector), attribute 0 for fold op."); - AddAttr>("kernel_sizes", - "(std::vector), attribute 1 for fold op."); - AddAttr>("strides", - "(std::vector), attribute 2 for fold op."); - AddAttr>("paddings", - "(std::vector), attribute 3 for fold op."); - AddAttr>("dilations", - "(std::vector), attribute 4 for fold op."); - AddComment(R"DOC( -TODO: Documentation of fold op. -)DOC"); - } -}; - -class FoldOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fold, - FoldInferShapeFunctor, - PD_INFER_META(phi::FoldInferMeta)); - -class FrameOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of frame op."); - AddOutput("Out", "(Tensor), output 0 of frame op."); - AddAttr("frame_length", "(int), attribute 0 for frame op."); - AddAttr("hop_length", "(int), attribute 1 for frame op."); - AddAttr("axis", "(int), attribute 2 for frame op.").SetDefault(-1); - AddComment(R"DOC( -TODO: Documentation of frame op. -)DOC"); - } -}; - -class FrameOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(frame, - FrameInferShapeFunctor, - PD_INFER_META(phi::FrameInferMeta)); - -class GatherNdOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of gather_nd op."); - AddInput("Index", "(Tensor), input 1 of gather_nd op."); - AddOutput("Out", "(Tensor), output 0 of gather_nd op."); - AddComment(R"DOC( -TODO: Documentation of gather_nd op. -)DOC"); - } -}; - -class GatherNdOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gather_nd, - GatherNdInferShapeFunctor, - PD_INFER_META(phi::GatherNdInferMeta)); - -class GatherTreeOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Ids", "(Tensor), input 0 of gather_tree op."); - AddInput("Parents", "(Tensor), input 1 of gather_tree op."); - AddOutput("Out", "(Tensor), output 0 of gather_tree op."); - AddComment(R"DOC( -TODO: Documentation of gather_tree op. -)DOC"); - } -}; - -class GatherTreeOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Ids"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gather_tree, - GatherTreeInferShapeFunctor, - PD_INFER_META(phi::GatherTreeMeta)); - -class GeluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of gelu op."); - AddOutput("Out", "(Tensor), output 0 of gelu op."); - AddAttr("approximate", "(bool), attribute 0 for gelu op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of gelu op. -)DOC"); - } -}; - -class GeluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gelu, - GeluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class GridSamplerOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of grid_sampler op."); - AddInput("Grid", "(Tensor), input 1 of grid_sampler op."); - AddOutput("Output", "(Tensor), output 0 of grid_sampler op."); - AddAttr("mode", - "(std::string), attribute 0 for grid_sampler op.") - .SetDefault("bilinear"); - AddAttr("padding_mode", - "(std::string), attribute 1 for grid_sampler op.") - .SetDefault("zeros"); - AddAttr("align_corners", "(bool), attribute 2 for grid_sampler op.") - .SetDefault(true); - AddComment(R"DOC( -TODO: Documentation of grid_sampler op. -)DOC"); - } -}; - -class GridSamplerOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(grid_sampler, - GridSamplerInferShapeFunctor, - PD_INFER_META(phi::GridSampleBaseInferMeta)); - -class GumbelSoftmaxOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of gumbel_softmax op."); - AddOutput("Out", "(Tensor), output 0 of gumbel_softmax op."); - AddAttr("temperature", "(float), attribute 0 for gumbel_softmax op.") - .SetDefault(1.0); - AddAttr("hard", "(bool), attribute 1 for gumbel_softmax op.") - .SetDefault(false); - AddAttr("axis", "(int), attribute 2 for gumbel_softmax op.") - .SetDefault(-1); - AddComment(R"DOC( -TODO: Documentation of gumbel_softmax op. -)DOC"); - } -}; - -class GumbelSoftmaxOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gumbel_softmax, - GumbelSoftmaxInferShapeFunctor, - PD_INFER_META(phi::GumbelSoftmaxInferMeta)); - -class HardShrinkOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of hard_shrink op."); - AddOutput("Out", "(Tensor), output 0 of hard_shrink op."); - AddAttr("threshold", "(float), attribute 0 for hard_shrink op.") - .SetDefault(0.5); - AddComment(R"DOC( -TODO: Documentation of hard_shrink op. -)DOC"); - } -}; - -class HardShrinkOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(hard_shrink, - HardShrinkInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class HardSigmoidOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of hard_sigmoid op."); - AddOutput("Out", "(Tensor), output 0 of hard_sigmoid op."); - AddAttr("slope", "(float), attribute 0 for hard_sigmoid op.") - .SetDefault(0.2); - AddAttr("offset", "(float), attribute 1 for hard_sigmoid op.") - .SetDefault(0.5); - AddComment(R"DOC( -TODO: Documentation of hard_sigmoid op. -)DOC"); - } -}; - -class HardSigmoidOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(hard_sigmoid, - HardSigmoidInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class BreluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of brelu op."); - AddOutput("Out", "(Tensor), output 0 of brelu op."); - AddAttr("t_min", "(float), attribute 0 for brelu op.").SetDefault(0); - AddAttr("t_max", "(float), attribute 1 for brelu op.") - .SetDefault(24); - AddComment(R"DOC( -TODO: Documentation of brelu op. -)DOC"); - } -}; - -class BreluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(brelu, - BreluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class HistogramOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of histogram op."); - AddOutput("Out", "(Tensor), output 0 of histogram op."); - AddAttr("bins", "(int64_t), attribute 0 for histogram op.") - .SetDefault(100); - AddAttr("min", "(int), attribute 1 for histogram op.").SetDefault(0); - AddAttr("max", "(int), attribute 2 for histogram op.").SetDefault(0); - AddComment(R"DOC( -TODO: Documentation of histogram op. -)DOC"); - } -}; - -class HistogramOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(histogram, - HistogramInferShapeFunctor, - PD_INFER_META(phi::HistogramInferMeta)); - -class ImagOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of imag op."); - AddOutput("Out", "(Tensor), output 0 of imag op."); - AddComment(R"DOC( -TODO: Documentation of imag op. -)DOC"); - } -}; - -class ImagOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(imag, - ImagInferShapeFunctor, - PD_INFER_META(phi::RealAndImagInferMeta)); - -class IndexSampleOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of index_sample op."); - AddInput("Index", "(Tensor), input 1 of index_sample op."); - AddOutput("Out", "(Tensor), output 0 of index_sample op."); - AddComment(R"DOC( -TODO: Documentation of index_sample op. -)DOC"); - } -}; - -class IndexSampleOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(index_sample, - IndexSampleInferShapeFunctor, - PD_INFER_META(phi::IndexSampleInferMeta)); - -class IndexSelectOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of index_select op."); - AddInput("Index", "(Tensor), input 1 of index_select op."); - AddOutput("Out", "(Tensor), output 0 of index_select op."); - AddAttr("dim", "(int), attribute 0 for index_select op.") - .SetDefault(0); - AddComment(R"DOC( -TODO: Documentation of index_select op. -)DOC"); - } -}; - -class IndexSelectOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(index_select, - IndexSelectInferShapeFunctor, - PD_INFER_META(phi::IndexSelectInferMeta)); - -class InverseOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of inverse op."); - AddOutput("Output", "(Tensor), output 0 of inverse op."); - AddComment(R"DOC( -TODO: Documentation of inverse op. -)DOC"); - } -}; - -class InverseOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(inverse, - InverseInferShapeFunctor, - PD_INFER_META(phi::InverseInferMeta)); - -class IsEmptyOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of is_empty op."); - AddOutput("Out", "(Tensor), output 0 of is_empty op."); - AddComment(R"DOC( -TODO: Documentation of is_empty op. -)DOC"); - } -}; - -class IsEmptyOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(is_empty, - IsEmptyInferShapeFunctor, - PD_INFER_META(phi::IsEmptyInferMeta)); - -class IscloseOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of isclose op."); - AddInput("Other", "(Tensor), input 1 of isclose op."); - AddOutput("Out", "(Tensor), output 0 of isclose op."); - AddInput("Rtol", "attribute 0 for isclose op from 0D Tensor.") - .AsDispensable(); - AddAttr("rtol", "(std::string), attribute 0 for isclose op.") - .SetDefault("1e-5"); - AddInput("Atol", "attribute 1 for isclose op from 0D Tensor.") - .AsDispensable(); - AddAttr("atol", "(std::string), attribute 1 for isclose op.") - .SetDefault("1e-8"); - AddAttr("equal_nan", "(bool), attribute 2 for isclose op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of isclose op. -)DOC"); - } -}; - -class IscloseOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(isclose, - IscloseInferShapeFunctor, - PD_INFER_META(phi::ValueCompareInferMeta)); - -class IsfiniteV2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of isfinite_v2 op."); - AddOutput("Out", "(Tensor), output 0 of isfinite_v2 op."); - AddComment(R"DOC( -TODO: Documentation of isfinite_v2 op. -)DOC"); - } -}; - -class IsfiniteV2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(isfinite_v2, - IsfiniteV2InferShapeFunctor, - PD_INFER_META(phi::IsfiniteInferMeta)); - -class IsinfV2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of isinf_v2 op."); - AddOutput("Out", "(Tensor), output 0 of isinf_v2 op."); - AddComment(R"DOC( -TODO: Documentation of isinf_v2 op. -)DOC"); - } -}; - -class IsinfV2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(isinf_v2, - IsinfV2InferShapeFunctor, - PD_INFER_META(phi::IsfiniteInferMeta)); - -class IsnanV2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of isnan_v2 op."); - AddOutput("Out", "(Tensor), output 0 of isnan_v2 op."); - AddComment(R"DOC( -TODO: Documentation of isnan_v2 op. -)DOC"); - } -}; - -class IsnanV2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(isnan_v2, - IsnanV2InferShapeFunctor, - PD_INFER_META(phi::IsfiniteInferMeta)); - -class KthvalueOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of kthvalue op."); - AddOutput("Out", "(Tensor), output 0 of kthvalue op."); - AddOutput("Indices", "(Tensor), output 1 of kthvalue op."); - AddAttr("k", "(int), attribute 0 for kthvalue op.").SetDefault(1); - AddAttr("axis", "(int), attribute 1 for kthvalue op.").SetDefault(-1); - AddAttr("keepdim", "(bool), attribute 2 for kthvalue op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of kthvalue op. -)DOC"); - } -}; - -class KthvalueOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(kthvalue, - KthvalueInferShapeFunctor, - PD_INFER_META(phi::KthvalueInferMeta)); - -class LabelSmoothOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of label_smooth op."); - AddInput("PriorDist", "(Tensor), input 1 of label_smooth op.") - .AsDispensable(); - AddOutput("Out", "(Tensor), output 0 of label_smooth op."); - AddAttr("epsilon", "(float), attribute 0 for label_smooth op.") - .SetDefault(0.0f); - AddComment(R"DOC( -TODO: Documentation of label_smooth op. -)DOC"); - } -}; - -class LabelSmoothOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(label_smooth, - LabelSmoothInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class LeakyReluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of leaky_relu op."); - AddOutput("Out", "(Tensor), output 0 of leaky_relu op."); - AddAttr("alpha", "(float), attribute 0 for leaky_relu op.") - .SetDefault(0.02f); - AddComment(R"DOC( -TODO: Documentation of leaky_relu op. -)DOC"); - } -}; - -class LeakyReluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(leaky_relu, - LeakyReluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class LerpOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of lerp op."); - AddInput("Y", "(Tensor), input 1 of lerp op."); - AddInput("Weight", "(Tensor), input 2 of lerp op."); - AddOutput("Out", "(Tensor), output 0 of lerp op."); - AddComment(R"DOC( -TODO: Documentation of lerp op. -)DOC"); - } -}; - -class LerpOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(lerp, - LerpInferShapeFunctor, - PD_INFER_META(phi::LerpInferMeta)); -DECLARE_INPLACE_OP_INFERER(LerpInplaceInferer, {"X", "Out"}); - -class LgammaOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of lgamma op."); - AddOutput("Out", "(Tensor), output 0 of lgamma op."); - AddComment(R"DOC( -TODO: Documentation of lgamma op. -)DOC"); - } -}; - -class LgammaOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(lgamma, - LgammaInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class LogOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of log op."); - AddOutput("Out", "(Tensor), output 0 of log op."); - AddComment(R"DOC( -TODO: Documentation of log op. -)DOC"); - } -}; - -class LogOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log, - LogInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class Log10OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of log10 op."); - AddOutput("Out", "(Tensor), output 0 of log10 op."); - AddComment(R"DOC( -TODO: Documentation of log10 op. -)DOC"); - } -}; - -class Log10Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log10, - Log10InferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class Log1pOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of log1p op."); - AddOutput("Out", "(Tensor), output 0 of log1p op."); - AddComment(R"DOC( -TODO: Documentation of log1p op. -)DOC"); - } -}; - -class Log1pOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log1p, - Log1pInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class Log2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of log2 op."); - AddOutput("Out", "(Tensor), output 0 of log2 op."); - AddComment(R"DOC( -TODO: Documentation of log2 op. -)DOC"); - } -}; - -class Log2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log2, - Log2InferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class LogLossOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Predicted", "(Tensor), input 0 of log_loss op."); - AddInput("Labels", "(Tensor), input 1 of log_loss op."); - AddOutput("Loss", "(Tensor), output 0 of log_loss op."); - AddAttr("epsilon", "(float), attribute 0 for log_loss op."); - AddComment(R"DOC( -TODO: Documentation of log_loss op. -)DOC"); - } -}; - -class LogLossOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log_loss, - LogLossInferShapeFunctor, - PD_INFER_META(phi::LogLossInferMeta)); - -class LogitOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of logit op."); - AddOutput("Out", "(Tensor), output 0 of logit op."); - AddAttr("eps", "(float), attribute 0 for logit op.") - .SetDefault(1e-6f); - AddComment(R"DOC( -TODO: Documentation of logit op. -)DOC"); - } -}; - -class LogitOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(logit, - LogitInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class LogsigmoidOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of logsigmoid op."); - AddOutput("Out", "(Tensor), output 0 of logsigmoid op."); - AddComment(R"DOC( -TODO: Documentation of logsigmoid op. -)DOC"); - } -}; - -class LogsigmoidOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(logsigmoid, - LogsigmoidInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class LuUnpackOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of lu_unpack op."); - AddInput("Pivots", "(Tensor), input 1 of lu_unpack op."); - AddOutput("Pmat", "(Tensor), output 0 of lu_unpack op."); - AddOutput("L", "(Tensor), output 1 of lu_unpack op."); - AddOutput("U", "(Tensor), output 2 of lu_unpack op."); - AddAttr("unpack_ludata", "(bool), attribute 0 for lu_unpack op.") - .SetDefault(true); - AddAttr("unpack_pivots", "(bool), attribute 1 for lu_unpack op.") - .SetDefault(true); - AddComment(R"DOC( -TODO: Documentation of lu_unpack op. -)DOC"); - } -}; - -class LuUnpackOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(lu_unpack, - LuUnpackInferShapeFunctor, - PD_INFER_META(phi::LUUnpackInferMeta)); - -class MaskedSelectOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of masked_select op."); - AddInput("Mask", "(Tensor), input 1 of masked_select op."); - AddOutput("Y", "(Tensor), output 0 of masked_select op."); - AddComment(R"DOC( -TODO: Documentation of masked_select op. -)DOC"); - } -}; - -class MaskedSelectOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(masked_select, - MaskedSelectInferShapeFunctor, - PD_INFER_META(phi::MaskedSelectInferMeta)); - -class MatrixPowerOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of matrix_power op."); - AddOutput("Out", "(Tensor), output 0 of matrix_power op."); - AddAttr("n", "(int), attribute 0 for matrix_power op."); - AddComment(R"DOC( -TODO: Documentation of matrix_power op. -)DOC"); - } -}; - -class MatrixPowerOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(matrix_power, - MatrixPowerInferShapeFunctor, - PD_INFER_META(phi::MatrixPowerInferMeta)); - -class MaxoutOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of maxout op."); - AddOutput("Out", "(Tensor), output 0 of maxout op."); - AddAttr("groups", "(int), attribute 0 for maxout op."); - AddAttr("axis", "(int), attribute 1 for maxout op.").SetDefault(1); - AddComment(R"DOC( -TODO: Documentation of maxout op. -)DOC"); - } -}; - -class MaxoutOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(maxout, - MaxoutInferShapeFunctor, - PD_INFER_META(phi::MaxOutInferMeta)); - -class ModeOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of mode op."); - AddOutput("Out", "(Tensor), output 0 of mode op."); - AddOutput("Indices", "(Tensor), output 1 of mode op."); - AddAttr("axis", "(int), attribute 0 for mode op.").SetDefault(-1); - AddAttr("keepdim", "(bool), attribute 1 for mode op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of mode op. -)DOC"); - } -}; - -class ModeOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(mode, - ModeInferShapeFunctor, - PD_INFER_META(phi::ModeInferMeta)); - -class MultinomialOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of multinomial op."); - AddOutput("Out", "(Tensor), output 0 of multinomial op."); - AddAttr("num_samples", "(int), attribute 0 for multinomial op.") - .SetDefault(1) - .SupportTensor(); - AddAttr("replacement", "(bool), attribute 1 for multinomial op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of multinomial op. -)DOC"); - } -}; - -class MultinomialOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(multinomial, - MultinomialInferShapeFunctor, - PD_INFER_META(phi::MultinomialInferMeta)); - -class MvOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of mv op."); - AddInput("Vec", "(Tensor), input 1 of mv op."); - AddOutput("Out", "(Tensor), output 0 of mv op."); - AddComment(R"DOC( -TODO: Documentation of mv op. -)DOC"); - } -}; - -class MvOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(mv, - MvInferShapeFunctor, - PD_INFER_META(phi::MvInferMeta)); - -class NllLossOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of nll_loss op."); - AddInput("Label", "(Tensor), input 1 of nll_loss op."); - AddInput("Weight", "(Tensor), input 2 of nll_loss op.").AsDispensable(); - AddOutput("Out", "(Tensor), output 0 of nll_loss op."); - AddOutput("Total_weight", "(Tensor), output 1 of nll_loss op."); - AddAttr("ignore_index", "(int64_t), attribute 0 for nll_loss op.") - .SetDefault(-100); - AddAttr("reduction", - "(std::string), attribute 1 for nll_loss op.") - .SetDefault("mean"); - AddComment(R"DOC( -TODO: Documentation of nll_loss op. -)DOC"); - } -}; - -class NllLossOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(nll_loss, - NllLossInferShapeFunctor, - PD_INFER_META(phi::NllLossRawInferMeta)); - -class NpuIdentityOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("x", "(Tensor), input 0 of npu_identity op."); - AddOutput("out", "(Tensor), output 0 of npu_identity op."); - AddAttr("format", "(int), attribute 0 for npu_identity op.") - .SetDefault(-1); - AddComment(R"DOC( -TODO: Documentation of npu_identity op. -)DOC"); - } -}; - -class NpuIdentityOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(npu_identity, - NpuIdentityInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class OverlapAddOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of overlap_add op."); - AddOutput("Out", "(Tensor), output 0 of overlap_add op."); - AddAttr("hop_length", "(int), attribute 0 for overlap_add op."); - AddAttr("axis", "(int), attribute 1 for overlap_add op.") - .SetDefault(-1); - AddComment(R"DOC( -TODO: Documentation of overlap_add op. -)DOC"); - } -}; - -class OverlapAddOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(overlap_add, - OverlapAddInferShapeFunctor, - PD_INFER_META(phi::OverlapAddInferMeta)); - -class PixelShuffleOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of pixel_shuffle op."); - AddOutput("Out", "(Tensor), output 0 of pixel_shuffle op."); - AddAttr("upscale_factor", "(int), attribute 0 for pixel_shuffle op.") - .SetDefault(1); - AddAttr("data_format", - "(std::string), attribute 1 for pixel_shuffle op.") - .SetDefault("NCHW"); - AddComment(R"DOC( -TODO: Documentation of pixel_shuffle op. -)DOC"); - } -}; - -class PixelShuffleOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(pixel_shuffle, - PixelShuffleInferShapeFunctor, - PD_INFER_META(phi::PixelShuffleInferMeta)); - -class PoissonOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of poisson op."); - AddOutput("Out", "(Tensor), output 0 of poisson op."); - AddComment(R"DOC( -TODO: Documentation of poisson op. -)DOC"); - } -}; - -class PoissonOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(poisson, - PoissonInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class PutAlongAxisOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of put_along_axis op."); - AddInput("Index", "(Tensor), input 1 of put_along_axis op."); - AddInput("Value", "(Tensor), input 2 of put_along_axis op."); - AddOutput("Result", "(Tensor), output 0 of put_along_axis op."); - AddAttr("Axis", "(int), attribute 0 for put_along_axis op."); - AddAttr("Reduce", - "(std::string), attribute 1 for put_along_axis op.") - .SetDefault("assign"); - AddComment(R"DOC( -TODO: Documentation of put_along_axis op. -)DOC"); - } -}; - -class PutAlongAxisOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(put_along_axis, - PutAlongAxisInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(PutAlongAxisInplaceInferer, {"Input", "Result"}); - -class QrOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of qr op."); - AddOutput("Q", "(Tensor), output 0 of qr op."); - AddOutput("R", "(Tensor), output 1 of qr op."); - AddAttr("mode", "(std::string), attribute 0 for qr op.") - .SetDefault("reduced"); - AddComment(R"DOC( -TODO: Documentation of qr op. -)DOC"); - } -}; - -class QrOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(qr, - QrInferShapeFunctor, - PD_INFER_META(phi::QrInferMeta)); - -class RealOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of real op."); - AddOutput("Out", "(Tensor), output 0 of real op."); - AddComment(R"DOC( -TODO: Documentation of real op. -)DOC"); - } -}; - -class RealOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(real, - RealInferShapeFunctor, - PD_INFER_META(phi::RealAndImagInferMeta)); - -class ReciprocalOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of reciprocal op."); - AddOutput("Out", "(Tensor), output 0 of reciprocal op."); - AddComment(R"DOC( -TODO: Documentation of reciprocal op. -)DOC"); - } -}; - -class ReciprocalOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(reciprocal, - ReciprocalInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ReciprocalInplaceInferer, {"X", "Out"}); - -class ReluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of relu op."); - AddOutput("Out", "(Tensor), output 0 of relu op."); - AddComment(R"DOC( -TODO: Documentation of relu op. -)DOC"); - } -}; - -class ReluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(relu, - ReluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ReluInplaceInferer, {"X", "Out"}); - -class RenormOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of renorm op."); - AddOutput("Out", "(Tensor), output 0 of renorm op."); - AddAttr("p", "(float), attribute 0 for renorm op."); - AddAttr("axis", "(int), attribute 1 for renorm op."); - AddAttr("max_norm", "(float), attribute 2 for renorm op."); - AddComment(R"DOC( -TODO: Documentation of renorm op. -)DOC"); - } -}; - -class RenormOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(renorm, - RenormInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class RollOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of roll op."); - AddOutput("Out", "(Tensor), output 0 of roll op."); - AddInput("ShiftsTensor", "attribute 0 for roll op from 1D integer Tensor.") - .AsDispensable(); - AddAttr>( - "shifts", "(std::vector), attribute 0 for roll op.") - .SetDefault({}); - AddAttr>( - "axis", "(std::vector), attribute 1 for roll op.") - .SetDefault({}); - AddComment(R"DOC( -TODO: Documentation of roll op. -)DOC"); - } -}; - -class RollOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(roll, - RollInferShapeFunctor, - PD_INFER_META(phi::RollInferMeta)); - -class RoundOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of round op."); - AddOutput("Out", "(Tensor), output 0 of round op."); - AddComment(R"DOC( -TODO: Documentation of round op. -)DOC"); - } -}; - -class RoundOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(round, - RoundInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(RoundInplaceInferer, {"X", "Out"}); - -class RsqrtOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of rsqrt op."); - AddOutput("Out", "(Tensor), output 0 of rsqrt op."); - AddComment(R"DOC( -TODO: Documentation of rsqrt op. -)DOC"); - } -}; - -class RsqrtOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(rsqrt, - RsqrtInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(RsqrtInplaceInferer, {"X", "Out"}); - -class ScatterOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of scatter op."); - AddInput("Ids", "(Tensor), input 1 of scatter op."); - AddInput("Updates", "(Tensor), input 2 of scatter op."); - AddOutput("Out", "(Tensor), output 0 of scatter op."); - AddAttr("overwrite", "(bool), attribute 0 for scatter op.") - .SetDefault(true); - AddComment(R"DOC( -TODO: Documentation of scatter op. -)DOC"); - } -}; - -class ScatterOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(scatter, - ScatterInferShapeFunctor, - PD_INFER_META(phi::ScatterInferMeta)); -DECLARE_INPLACE_OP_INFERER(ScatterInplaceInferer, {"X", "Out"}); - -class ScatterNdAddOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of scatter_nd_add op."); - AddInput("Index", "(Tensor), input 1 of scatter_nd_add op."); - AddInput("Updates", "(Tensor), input 2 of scatter_nd_add op."); - AddOutput("Out", "(Tensor), output 0 of scatter_nd_add op."); - AddComment(R"DOC( -TODO: Documentation of scatter_nd_add op. -)DOC"); - } -}; - -class ScatterNdAddOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(scatter_nd_add, - ScatterNdAddInferShapeFunctor, - PD_INFER_META(phi::ScatterNdAddInferMeta)); - -class SearchsortedOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("SortedSequence", "(Tensor), input 0 of searchsorted op."); - AddInput("Values", "(Tensor), input 1 of searchsorted op."); - AddOutput("Out", "(Tensor), output 0 of searchsorted op."); - AddAttr("out_int32", "(bool), attribute 0 for searchsorted op.") - .SetDefault(false); - AddAttr("right", "(bool), attribute 1 for searchsorted op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of searchsorted op. -)DOC"); - } -}; - -class SearchsortedOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, "SortedSequence"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(searchsorted, - SearchsortedInferShapeFunctor, - PD_INFER_META(phi::SearchsortedInferMeta)); - -class SeluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of selu op."); - AddOutput("Out", "(Tensor), output 0 of selu op."); - AddAttr("scale", "(float), attribute 0 for selu op.") - .SetDefault(1.0507009873554804934193349852946); - AddAttr("alpha", "(float), attribute 1 for selu op.") - .SetDefault(1.6732632423543772848170429916717); - AddComment(R"DOC( -TODO: Documentation of selu op. -)DOC"); - } -}; - -class SeluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(selu, - SeluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class GraphSendUvOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("x", "(Tensor), input 0 of graph_send_uv op."); - AddInput("y", "(Tensor), input 1 of graph_send_uv op."); - AddInput("src_index", "(Tensor), input 2 of graph_send_uv op."); - AddInput("dst_index", "(Tensor), input 3 of graph_send_uv op."); - AddOutput("out", "(Tensor), output 0 of graph_send_uv op."); - AddAttr("message_op", - "(std::string), attribute 0 for graph_send_uv op.") - .SetDefault("ADD"); - AddComment(R"DOC( -TODO: Documentation of graph_send_uv op. -)DOC"); - } -}; - -class GraphSendUvOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "x"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(graph_send_uv, - GraphSendUvInferShapeFunctor, - PD_INFER_META(phi::SendUVInferMeta)); - -class ShardIndexOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of shard_index op."); - AddOutput("Out", "(Tensor), output 0 of shard_index op."); - AddAttr("index_num", "(int), attribute 0 for shard_index op."); - AddAttr("nshards", "(int), attribute 1 for shard_index op."); - AddAttr("shard_id", "(int), attribute 2 for shard_index op."); - AddAttr("ignore_value", "(int), attribute 3 for shard_index op.") - .SetDefault(-1); - AddComment(R"DOC( -TODO: Documentation of shard_index op. -)DOC"); - } -}; - -class ShardIndexOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(shard_index, - ShardIndexInferShapeFunctor, - PD_INFER_META(phi::ShardIndexInferMeta)); - -class SigmoidOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of sigmoid op."); - AddOutput("Out", "(Tensor), output 0 of sigmoid op."); - AddComment(R"DOC( -TODO: Documentation of sigmoid op. -)DOC"); - } -}; - -class SigmoidOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sigmoid, - SigmoidInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SiluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of silu op."); - AddOutput("Out", "(Tensor), output 0 of silu op."); - AddComment(R"DOC( -TODO: Documentation of silu op. -)DOC"); - } -}; - -class SiluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(silu, - SiluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SinOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of sin op."); - AddOutput("Out", "(Tensor), output 0 of sin op."); - AddComment(R"DOC( -TODO: Documentation of sin op. -)DOC"); - } -}; - -class SinOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sin, - SinInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SinhOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of sinh op."); - AddOutput("Out", "(Tensor), output 0 of sinh op."); - AddComment(R"DOC( -TODO: Documentation of sinh op. -)DOC"); - } -}; - -class SinhOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sinh, - SinhInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SoftplusOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of softplus op."); - AddOutput("Out", "(Tensor), output 0 of softplus op."); - AddAttr("beta", "(float), attribute 0 for softplus op.") - .SetDefault(1.0); - AddAttr("threshold", "(float), attribute 1 for softplus op.") - .SetDefault(20.0f); - AddComment(R"DOC( -TODO: Documentation of softplus op. -)DOC"); - } -}; - -class SoftplusOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(softplus, - SoftplusInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SoftshrinkOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of softshrink op."); - AddOutput("Out", "(Tensor), output 0 of softshrink op."); - AddAttr("lambda", "(float), attribute 0 for softshrink op.") - .SetDefault(0.5); - AddComment(R"DOC( -TODO: Documentation of softshrink op. -)DOC"); - } -}; - -class SoftshrinkOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(softshrink, - SoftshrinkInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SoftsignOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of softsign op."); - AddOutput("Out", "(Tensor), output 0 of softsign op."); - AddComment(R"DOC( -TODO: Documentation of softsign op. -)DOC"); - } -}; - -class SoftsignOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(softsign, - SoftsignInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class SolveOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of solve op."); - AddInput("Y", "(Tensor), input 1 of solve op."); - AddOutput("Out", "(Tensor), output 0 of solve op."); - AddComment(R"DOC( -TODO: Documentation of solve op. -)DOC"); - } -}; - -class SolveOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(solve, - SolveInferShapeFunctor, - PD_INFER_META(phi::SolveInferMeta)); - -class SqrtOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of sqrt op."); - AddOutput("Out", "(Tensor), output 0 of sqrt op."); - AddComment(R"DOC( -TODO: Documentation of sqrt op. -)DOC"); - } -}; - -class SqrtOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sqrt, - SqrtInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SqrtInplaceInferer, {"X", "Out"}); - -class SquareOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of square op."); - AddOutput("Out", "(Tensor), output 0 of square op."); - AddComment(R"DOC( -TODO: Documentation of square op. -)DOC"); - } -}; - -class SquareOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(square, - SquareInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class Squeeze2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of squeeze2 op."); - AddOutput("Out", "(Tensor), output 0 of squeeze2 op."); - AddOutput("XShape", "(Tensor), output 1 of squeeze2 op.") - .AsIntermediate() - .AsExtra(); - AddAttr>( - "axes", "(std::vector), attribute 0 for squeeze2 op.") - .SetDefault({}) - .SupportTensor(); - AddComment(R"DOC( -TODO: Documentation of squeeze2 op. -)DOC"); - } -}; - -class Squeeze2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(squeeze2, - Squeeze2InferShapeFunctor, - PD_INFER_META(phi::SqueezeWithXShapeInferMeta)); -DECLARE_INPLACE_OP_INFERER(Squeeze2InplaceInferer, {"X", "Out"}); - -class SvdOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of svd op."); - AddOutput("U", "(Tensor), output 0 of svd op."); - AddOutput("S", "(Tensor), output 1 of svd op."); - AddOutput("VH", "(Tensor), output 2 of svd op."); - AddAttr("full_matrices", "(bool), attribute 0 for svd op.") - .SetDefault(false); - AddComment(R"DOC( -TODO: Documentation of svd op. -)DOC"); - } -}; - -class SvdOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(svd, - SvdInferShapeFunctor, - PD_INFER_META(phi::SvdInferMeta)); - -class TakeAlongAxisOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of take_along_axis op."); - AddInput("Index", "(Tensor), input 1 of take_along_axis op."); - AddOutput("Result", "(Tensor), output 0 of take_along_axis op."); - AddAttr("Axis", "(int), attribute 0 for take_along_axis op."); - AddComment(R"DOC( -TODO: Documentation of take_along_axis op. -)DOC"); - } -}; - -class TakeAlongAxisOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(take_along_axis, - TakeAlongAxisInferShapeFunctor, - PD_INFER_META(phi::TakeAlongAxisInferMeta)); - -class TanOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of tan op."); - AddOutput("Out", "(Tensor), output 0 of tan op."); - AddComment(R"DOC( -TODO: Documentation of tan op. -)DOC"); - } -}; - -class TanOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tan, - TanInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class TanhOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of tanh op."); - AddOutput("Out", "(Tensor), output 0 of tanh op."); - AddComment(R"DOC( -TODO: Documentation of tanh op. -)DOC"); - } -}; - -class TanhOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tanh, - TanhInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(TanhInplaceInferer, {"X", "Out"}); - -class TanhShrinkOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of tanh_shrink op."); - AddOutput("Out", "(Tensor), output 0 of tanh_shrink op."); - AddComment(R"DOC( -TODO: Documentation of tanh_shrink op. -)DOC"); - } -}; - -class TanhShrinkOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tanh_shrink, - TanhShrinkInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class ThresholdedReluOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of thresholded_relu op."); - AddOutput("Out", "(Tensor), output 0 of thresholded_relu op."); - AddAttr("threshold", "(float), attribute 0 for thresholded_relu op.") - .SetDefault(1.0); - AddComment(R"DOC( -TODO: Documentation of thresholded_relu op. -)DOC"); - } -}; - -class ThresholdedReluOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(thresholded_relu, - ThresholdedReluInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class TopKV2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of top_k_v2 op."); - AddOutput("Out", "(Tensor), output 0 of top_k_v2 op."); - AddOutput("Indices", "(Tensor), output 1 of top_k_v2 op."); - AddInput("K", "attribute 0 for top_k_v2 op from 0D Tensor.") - .AsDispensable(); - AddAttr("k", "(int), attribute 0 for top_k_v2 op.").SetDefault(1); - AddAttr("axis", "(int), attribute 1 for top_k_v2 op.").SetDefault(-1); - AddAttr("largest", "(bool), attribute 2 for top_k_v2 op.") - .SetDefault(true); - AddAttr("sorted", "(bool), attribute 3 for top_k_v2 op.") - .SetDefault(true); - AddComment(R"DOC( -TODO: Documentation of top_k_v2 op. -)DOC"); - } -}; - -class TopKV2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(top_k_v2, - TopKV2InferShapeFunctor, - PD_INFER_META(phi::TopKInferMeta)); - -class TraceOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of trace op."); - AddOutput("Out", "(Tensor), output 0 of trace op."); - AddAttr("offset", "(int), attribute 0 for trace op.").SetDefault(0); - AddAttr("axis1", "(int), attribute 1 for trace op.").SetDefault(0); - AddAttr("axis2", "(int), attribute 2 for trace op.").SetDefault(1); - AddComment(R"DOC( -TODO: Documentation of trace op. -)DOC"); - } -}; - -class TraceOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(trace, - TraceInferShapeFunctor, - PD_INFER_META(phi::TraceInferMeta)); - -class TruncOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of trunc op."); - AddOutput("Out", "(Tensor), output 0 of trunc op."); - AddComment(R"DOC( -TODO: Documentation of trunc op. -)DOC"); - } -}; - -class TruncOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(trunc, - TruncInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -class UnfoldOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of unfold op."); - AddOutput("Y", "(Tensor), output 0 of unfold op."); - AddAttr>("kernel_sizes", - "(std::vector), attribute 0 for unfold op."); - AddAttr>("strides", - "(std::vector), attribute 1 for unfold op."); - AddAttr>("paddings", - "(std::vector), attribute 2 for unfold op."); - AddAttr>("dilations", - "(std::vector), attribute 3 for unfold op."); - AddComment(R"DOC( -TODO: Documentation of unfold op. -)DOC"); - } -}; - -class UnfoldOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(unfold, - UnfoldInferShapeFunctor, - PD_INFER_META(phi::UnfoldInferMeta)); - -class Unsqueeze2OpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of unsqueeze2 op."); - AddOutput("Out", "(Tensor), output 0 of unsqueeze2 op."); - AddOutput("XShape", "(Tensor), output 1 of unsqueeze2 op.") - .AsIntermediate() - .AsExtra(); - AddInput("AxesTensor", - "attribute 0 for unsqueeze2 op from 1D integer Tensor.") - .AsDispensable(); - AddInput("AxesTensorList", - "attribute 0 for unsqueeze2 op from list fo 0D integer Tensors.") - .AsDuplicable() - .AsDispensable(); - AddAttr>( - "axes", "(std::vector), attribute 0 for unsqueeze2 op.") - .SetDefault({}); - AddComment(R"DOC( -TODO: Documentation of unsqueeze2 op. -)DOC"); - } -}; - -class Unsqueeze2Op : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(unsqueeze2, - Unsqueeze2InferShapeFunctor, - PD_INFER_META(phi::UnsqueezeWithXShapeInferMeta)); -DECLARE_INPLACE_OP_INFERER(Unsqueeze2InplaceInferer, {"X", "Out"}); - -class UnstackOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("X", "(Tensor), input 0 of unstack op."); - AddOutput("Y", "(Tensor[]), output 0 of unstack op.").AsDuplicable(); - AddAttr("axis", "(int), attribute 0 for unstack op.").SetDefault(0); - AddAttr("num", "(int), attribute 1 for unstack op.").SetDefault(0); - AddComment(R"DOC( -TODO: Documentation of unstack op. -)DOC"); - } -}; - -class UnstackOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(unstack, - UnstackInferShapeFunctor, - PD_INFER_META(phi::UnStackInferMeta)); - -class ViterbiDecodeOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Input", "(Tensor), input 0 of viterbi_decode op."); - AddInput("Transition", "(Tensor), input 1 of viterbi_decode op."); - AddInput("Length", "(Tensor), input 2 of viterbi_decode op."); - AddOutput("Scores", "(Tensor), output 0 of viterbi_decode op."); - AddOutput("Path", "(Tensor), output 1 of viterbi_decode op."); - AddAttr("include_bos_eos_tag", - "(bool), attribute 0 for viterbi_decode op.") - .SetDefault(true); - AddComment(R"DOC( -TODO: Documentation of viterbi_decode op. -)DOC"); - } -}; - -class ViterbiDecodeOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Input"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(viterbi_decode, - ViterbiDecodeInferShapeFunctor, - PD_INFER_META(phi::ViterbiDecodeInferMeta)); - -class WarprnntOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("input", "(Tensor), input 0 of warprnnt op."); - AddInput("label", "(Tensor), input 1 of warprnnt op."); - AddInput("input_lengths", "(Tensor), input 2 of warprnnt op."); - AddInput("label_lengths", "(Tensor), input 3 of warprnnt op."); - AddOutput("loss", "(Tensor), output 0 of warprnnt op."); - AddOutput("warprnntgrad", "(Tensor), output 1 of warprnnt op.") - .AsIntermediate(); - AddAttr("blank", "(int), attribute 0 for warprnnt op.").SetDefault(0); - AddAttr("fastemit_lambda", "(float), attribute 1 for warprnnt op.") - .SetDefault(0.0); - AddComment(R"DOC( -TODO: Documentation of warprnnt op. -)DOC"); - } -}; - -class WarprnntOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "input"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(warprnnt, - WarprnntInferShapeFunctor, - PD_INFER_META(phi::WarprnntInferMeta)); - -class WhereOpMaker : public framework::OpProtoAndCheckerMaker { - public: - void Make() override { - AddInput("Condition", "(Tensor), input 0 of where op."); - AddInput("X", "(Tensor), input 1 of where op."); - AddInput("Y", "(Tensor), input 2 of where op."); - AddOutput("Out", "(Tensor), output 0 of where op."); - AddComment(R"DOC( -TODO: Documentation of where op. -)DOC"); - } -}; - -class WhereOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(where, - WhereInferShapeFunctor, - PD_INFER_META(phi::WhereInferMeta)); - -template -class AcosGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("acos_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AcosGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(acos_grad, - AcosGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(AcosGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class AcoshGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("acosh_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AcoshGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(acosh_grad, - AcoshGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(AcoshGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class AddmmGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("addmm_grad"); - - grad_op->SetInput("Input", this->Input("Input")); - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AddmmGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(addmm_grad, - AddmmGradInferShapeFunctor, - PD_INFER_META(phi::GeneralTernaryGradInferMeta)); - -template -class AngleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("angle_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AngleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(angle_grad, - AngleGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class ArgsortGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("argsort_grad"); - - grad_op->SetInput("Indices", this->Output("Indices")); - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ArgsortGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(argsort_grad, - ArgsortGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(ArgsortGradNoNeedBufferVarInferer, "X"); - -template -class AsComplexGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("as_real"); - - grad_op->SetInput("X", this->OutputGrad("Out")); - - grad_op->SetOutput("Out", this->InputGrad("X")); - } -}; - -template -class AsRealGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("as_complex"); - - grad_op->SetInput("X", this->OutputGrad("Out")); - - grad_op->SetOutput("Out", this->InputGrad("X")); - } -}; - -template -class AsinGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("asin_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AsinGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(asin_grad, - AsinGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(AsinGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class AsinhGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("asinh_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AsinhGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(asinh_grad, - AsinhGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(AsinhGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class Atan2GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("atan2_grad"); - - grad_op->SetInput("X1", this->Input("X1")); - grad_op->SetInput("X2", this->Input("X2")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X1"), this->InputGrad("X1")); - grad_op->SetOutput(GradVarName("X2"), this->InputGrad("X2")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class Atan2GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(atan2_grad, - Atan2GradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class AtanGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("atan_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AtanGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(atan_grad, - AtanGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(AtanGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class AtanhGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("atanh_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class AtanhGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(atanh_grad, - AtanhGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(AtanhGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class BmmGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("bmm_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class BmmGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(bmm_grad, - BmmGradInferShapeFunctor, - PD_INFER_META(phi::BmmGradInferMeta)); - -template -class CeilGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("ceil_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CeilGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(ceil_grad, - CeilGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(CeilGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class CeluGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("celu_grad_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CeluGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(celu_grad_grad, - CeluGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(CeluGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class CeluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("celu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CeluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(celu_grad, - CeluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(CeluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class CholeskyGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cholesky_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CholeskyGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cholesky_grad, - CholeskyGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class CholeskySolveGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cholesky_solve_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CholeskySolveGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cholesky_solve_grad, - CholeskySolveGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class ClipDoubleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("clip_double_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - if (this->HasInput("Min")) { - grad_op->SetInput("Min", this->Input("Min")); - } - if (this->HasInput("Max")) { - grad_op->SetInput("Max", this->Input("Max")); - } - } -}; - -class ClipDoubleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(clip_double_grad, - ClipDoubleGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class ClipGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("clip_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - if (this->HasInput("Min")) { - grad_op->SetInput("Min", this->Input("Min")); - } - if (this->HasInput("Max")) { - grad_op->SetInput("Max", this->Input("Max")); - } - } -}; - -class ClipGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(clip_grad, - ClipGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ClipGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class ComplexGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("complex_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ComplexGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(complex_grad, - ComplexGradInferShapeFunctor, - PD_INFER_META(phi::ComplexGradInferMeta)); - -template -class ConjGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("conj"); - - grad_op->SetInput("X", this->OutputGrad("Out")); - - grad_op->SetOutput("Out", this->InputGrad("X")); - } -}; - -template -class CosDoubleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cos_double_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CosDoubleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cos_double_grad, - CosDoubleGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(CosDoubleGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class CosGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cos_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CosGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cos_grad, - CosGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(CosGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class CosTripleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cos_triple_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out_forward", this->Input("grad_out")); - grad_op->SetInput("grad_x_grad_forward", - this->Input(GradVarName("grad_x"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - grad_op->SetInput(GradVarName("grad_out_grad"), - this->OutputGrad(GradVarName("grad_out"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out_forward"), - this->InputGrad("grad_out")); - grad_op->SetOutput(GradVarName("grad_x_grad_forward"), - this->InputGrad(GradVarName("grad_x"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CosTripleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cos_triple_grad, - CosTripleGradInferShapeFunctor, - PD_INFER_META(phi::GeneralTernaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(CosTripleGradInplaceInferer, - {"grad_x_grad_forward", - GradVarName("grad_out_forward")}); - -template -class CoshGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cosh_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CoshGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cosh_grad, - CoshGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(CoshGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class CropTensorGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("crop_tensor_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - if (this->HasInput("Offsets")) { - grad_op->SetInput("Offsets", this->Input("Offsets")); - } - if (this->HasInput("OffsetsTensor")) { - grad_op->SetInput("OffsetsTensor", this->Input("OffsetsTensor")); - } - } -}; - -class CropTensorGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(crop_tensor_grad, - CropTensorGradInferShapeFunctor, - PD_INFER_META(phi::CropGradInferMeta)); - -template -class CrossGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("cross_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class CrossGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(cross_grad, - CrossGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class DeterminantGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("determinant_grad"); - - grad_op->SetInput("Input", this->Input("Input")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class DeterminantGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(determinant_grad, - DeterminantGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class DiagV2GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("diag_v2_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class DiagV2GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(diag_v2_grad, - DiagV2GradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(DiagV2GradNoNeedBufferVarInferer, "X"); - -template -class DiagonalGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("diagonal_grad"); - - grad_op->SetInput("Input", this->Input("Input")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class DiagonalGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(diagonal_grad, - DiagonalGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(DiagonalGradNoNeedBufferVarInferer, - "Input"); - -template -class DigammaGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("digamma_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class DigammaGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(digamma_grad, - DigammaGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class DistGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("dist_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class DistGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(dist_grad, - DistGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class DotGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("dot_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class DotGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(dot_grad, - DotGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class EigGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("eig_grad"); - - grad_op->SetInput("Eigenvalues", this->Output("Eigenvalues")); - grad_op->SetInput("Eigenvectors", this->Output("Eigenvectors")); - grad_op->SetInput(GradVarName("Eigenvalues"), - this->OutputGrad("Eigenvalues")); - grad_op->SetInput(GradVarName("Eigenvectors"), - this->OutputGrad("Eigenvectors")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class EigGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Eigenvectors"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(eig_grad, - EigGradInferShapeFunctor, - PD_INFER_META(phi::EigGradInferMeta)); - -template -class EighGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("eigh_grad"); - - grad_op->SetInput("Eigenvalues", this->Output("Eigenvalues")); - grad_op->SetInput("Eigenvectors", this->Output("Eigenvectors")); - grad_op->SetInput(GradVarName("Eigenvalues"), - this->OutputGrad("Eigenvalues")); - grad_op->SetInput(GradVarName("Eigenvectors"), - this->OutputGrad("Eigenvectors")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class EighGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Eigenvectors"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(eigh_grad, - EighGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class EluGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("elu_grad_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class EluGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(elu_grad_grad, - EluGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(EluGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class EluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("elu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class EluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(elu_grad, - EluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(EluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class ErfGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("erf_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ErfGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(erf_grad, - ErfGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class ErfinvGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("erfinv_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ErfinvGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(erfinv_grad, - ErfinvGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class ExpGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("exp_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ExpGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(exp_grad, - ExpGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ExpGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class Expm1GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("expm1_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class Expm1GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(expm1_grad, - Expm1GradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(Expm1GradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class FftC2cGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("fft_c2c_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FftC2cGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fft_c2c_grad, - FftC2cGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class FftC2rGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("fft_c2r_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FftC2rGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fft_c2r_grad, - FftC2rGradInferShapeFunctor, - PD_INFER_META(phi::FFTC2RGradInferMeta)); - -template -class FftR2cGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("fft_r2c_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FftR2cGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fft_r2c_grad, - FftR2cGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(FftR2cGradNoNeedBufferVarInferer, "X"); - -template -class FillDiagonalGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("fill_diagonal_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FillDiagonalGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fill_diagonal_grad, - FillDiagonalGradInferShapeFunctor, - PD_INFER_META(phi::FillDiagonalGradInferMeta)); - -template -class FillDiagonalTensorGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("fill_diagonal_tensor_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FillDiagonalTensorGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR( - fill_diagonal_tensor_grad, - FillDiagonalTensorGradInferShapeFunctor, - PD_INFER_META(phi::FillDiagonalTensorGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(FillDiagonalTensorGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class FlipGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("flip"); - - grad_op->SetInput("X", this->OutputGrad("Out")); - - grad_op->SetOutput("Out", this->InputGrad("X")); - - grad_op->SetAttr("axis", this->GetAttr("axis")); - } -}; - -template -class FloorGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("floor_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FloorGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(floor_grad, - FloorGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(FloorGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class FoldGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("fold_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Y"), this->OutputGrad("Y")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FoldGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Y")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(fold_grad, - FoldGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(FoldGradNoNeedBufferVarInferer, "X"); - -template -class FrameGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("frame_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class FrameGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(frame_grad, - FrameGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class GatherNdGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("gather_nd_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Index", this->Input("Index")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class GatherNdGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gather_nd_grad, - GatherNdGradInferShapeFunctor, - PD_INFER_META(phi::GatherNdGradInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(GatherNdGradNoNeedBufferVarInferer, "X"); - -template -class GeluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("gelu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class GeluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gelu_grad, - GeluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class GridSamplerGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("grid_sampler_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Grid", this->Input("Grid")); - grad_op->SetInput(GradVarName("Output"), this->OutputGrad("Output")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Grid"), this->InputGrad("Grid")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class GridSamplerGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(grid_sampler_grad, - GridSamplerGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class GumbelSoftmaxGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("gumbel_softmax_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class GumbelSoftmaxGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(gumbel_softmax_grad, - GumbelSoftmaxGradInferShapeFunctor, - PD_INFER_META(phi::GumbelSoftmaxGradInferMeta)); - -template -class HardShrinkGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("hard_shrink_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class HardShrinkGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(hard_shrink_grad, - HardShrinkGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(HardShrinkGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class HardSigmoidGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("hard_sigmoid_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class HardSigmoidGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(hard_sigmoid_grad, - HardSigmoidGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(HardSigmoidGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class BreluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("brelu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class BreluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(brelu_grad, - BreluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(BreluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class ImagGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("imag_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ImagGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - data_type = framework::ToComplexType(data_type); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(imag_grad, - ImagGradInferShapeFunctor, - PD_INFER_META(phi::RealAndImagGradInferMeta)); - -template -class IndexSampleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("index_sample_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Index", this->Input("Index")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class IndexSampleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(index_sample_grad, - IndexSampleGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(IndexSampleGradNoNeedBufferVarInferer, "X"); - -template -class IndexSelectGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("index_select_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Index", this->Input("Index")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class IndexSelectGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(index_select_grad, - IndexSelectGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(IndexSelectGradNoNeedBufferVarInferer, "X"); - -template -class InverseGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("inverse_grad"); - - grad_op->SetInput("Output", this->Output("Output")); - grad_op->SetInput(GradVarName("Output"), this->OutputGrad("Output")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class InverseGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(inverse_grad, - InverseGradInferShapeFunctor, - PD_INFER_META(phi::InverseGradInferMeta)); - -template -class KthvalueGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("kthvalue_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Indices", this->Output("Indices")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class KthvalueGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(kthvalue_grad, - KthvalueGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class LabelSmoothGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("label_smooth_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LabelSmoothGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(label_smooth_grad, - LabelSmoothGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class LeakyReluGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("leaky_relu_grad_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LeakyReluGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(leaky_relu_grad_grad, - LeakyReluGradGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(LeakyReluGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class LeakyReluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("leaky_relu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LeakyReluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(leaky_relu_grad, - LeakyReluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(LeakyReluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class LerpGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("lerp_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput("Weight", this->Input("Weight")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LerpGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(lerp_grad, - LerpGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class LgammaGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("lgamma_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LgammaGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(lgamma_grad, - LgammaGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class Log10GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("log10_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class Log10GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log10_grad, - Log10GradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(Log10GradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class Log1pGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("log1p_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class Log1pGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log1p_grad, - Log1pGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(Log1pGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class Log2GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("log2_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class Log2GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log2_grad, - Log2GradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(Log2GradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class LogGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("log_grad_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LogGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log_grad_grad, - LogGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(LogGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class LogGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("log_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LogGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log_grad, - LogGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(LogGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class LogLossGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("log_loss_grad"); - - grad_op->SetInput("Predicted", this->Input("Predicted")); - grad_op->SetInput("Labels", this->Input("Labels")); - grad_op->SetInput(GradVarName("Loss"), this->OutputGrad("Loss")); - - grad_op->SetOutput(GradVarName("Predicted"), this->InputGrad("Predicted")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LogLossGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(log_loss_grad, - LogLossGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class LogitGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("logit_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LogitGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(logit_grad, - LogitGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class LogsigmoidGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("logsigmoid_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LogsigmoidGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(logsigmoid_grad, - LogsigmoidGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(LogsigmoidGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class LuUnpackGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("lu_unpack_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Pivots", this->Input("Pivots")); - grad_op->SetInput("L", this->Output("L")); - grad_op->SetInput("U", this->Output("U")); - grad_op->SetInput("Pmat", this->Output("Pmat")); - grad_op->SetInput(GradVarName("L"), this->OutputGrad("L")); - grad_op->SetInput(GradVarName("U"), this->OutputGrad("U")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class LuUnpackGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(lu_unpack_grad, - LuUnpackGradInferShapeFunctor, - PD_INFER_META(phi::LUUnpackGradInferMeta)); - -template -class MaskedSelectGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("masked_select_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Mask", this->Input("Mask")); - grad_op->SetInput(GradVarName("Y"), this->OutputGrad("Y")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class MaskedSelectGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(masked_select_grad, - MaskedSelectGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(MaskedSelectGradNoNeedBufferVarInferer, - "X"); - -template -class MatrixPowerGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("matrix_power_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class MatrixPowerGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(matrix_power_grad, - MatrixPowerGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class MaxoutGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("maxout_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class MaxoutGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(maxout_grad, - MaxoutGradInferShapeFunctor, - PD_INFER_META(phi::GeneralUnaryGradInferMeta)); - -template -class ModeGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("mode_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Indices", this->Output("Indices")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ModeGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(mode_grad, - ModeGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class MvGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("mv_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Vec", this->Input("Vec")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Vec"), this->InputGrad("Vec")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class MvGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(mv_grad, - MvGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class NllLossGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("nll_loss_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Label", this->Input("Label")); - grad_op->SetInput("Weight", this->Input("Weight")); - grad_op->SetInput("Total_weight", this->Output("Total_weight")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class NllLossGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(nll_loss_grad, - NllLossGradInferShapeFunctor, - PD_INFER_META(phi::NllLossGradInferMeta)); - -template -class OverlapAddGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("overlap_add_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class OverlapAddGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(overlap_add_grad, - OverlapAddGradInferShapeFunctor, - PD_INFER_META(phi::OverlapAddGradInferMeta)); - -template -class PixelShuffleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("pixel_shuffle_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class PixelShuffleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(pixel_shuffle_grad, - PixelShuffleGradInferShapeFunctor, - PD_INFER_META(phi::PixelShuffleGradInferMeta)); - -template -class PoissonGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("poisson_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class PoissonGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(poisson_grad, - PoissonGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class PutAlongAxisGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("put_along_axis_grad"); - - grad_op->SetInput("Input", this->Input("Input")); - grad_op->SetInput("Index", this->Input("Index")); - grad_op->SetInput(GradVarName("Result"), this->OutputGrad("Result")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - grad_op->SetOutput(GradVarName("value"), this->InputGrad("Value")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class PutAlongAxisGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(put_along_axis_grad, - PutAlongAxisGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class QrGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("qr_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Q", this->Output("Q")); - grad_op->SetInput("R", this->Output("R")); - grad_op->SetInput(GradVarName("Q"), this->OutputGrad("Q")); - grad_op->SetInput(GradVarName("R"), this->OutputGrad("R")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class QrGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(qr_grad, - QrGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class RealGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("real_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class RealGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - data_type = framework::ToComplexType(data_type); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(real_grad, - RealGradInferShapeFunctor, - PD_INFER_META(phi::RealAndImagGradInferMeta)); - -template -class ReciprocalGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("reciprocal_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ReciprocalGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(reciprocal_grad, - ReciprocalGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ReciprocalGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class ReluGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("relu_grad_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ReluGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(relu_grad_grad, - ReluGradGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ReluGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class ReluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("relu_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ReluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(relu_grad, - ReluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ReluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class RenormGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("renorm_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class RenormGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(renorm_grad, - RenormGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class RollGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("roll_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - if (this->HasInput("ShiftsTensor")) { - grad_op->SetInput("ShiftsTensor", this->Input("ShiftsTensor")); - } - } -}; - -class RollGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "X"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(roll_grad, - RollGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(RollGradNoNeedBufferVarInferer, "X"); - -template -class RoundGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("round_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class RoundGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(round_grad, - RoundGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(RoundGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class RsqrtGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("rsqrt_grad_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput("grad_x", this->Output(GradVarName("X"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("Out"), this->InputGrad("Out")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class RsqrtGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(rsqrt_grad_grad, - RsqrtGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(RsqrtGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class RsqrtGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("rsqrt_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class RsqrtGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(rsqrt_grad, - RsqrtGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(RsqrtGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class ScatterGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("scatter_grad"); - - grad_op->SetInput("Ids", this->Input("Ids")); - grad_op->SetInput("Updates", this->Input("Updates")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Updates"), this->InputGrad("Updates")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ScatterGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(scatter_grad, - ScatterGradInferShapeFunctor, - PD_INFER_META(phi::ScatterGradInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(ScatterGradNoNeedBufferVarInferer, - "Updates"); - -template -class ScatterNdAddGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("scatter_nd_add_grad"); - - grad_op->SetInput("Index", this->Input("Index")); - grad_op->SetInput("Updates", this->Input("Updates")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Updates"), this->InputGrad("Updates")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ScatterNdAddGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(scatter_nd_add_grad, - ScatterNdAddGradInferShapeFunctor, - PD_INFER_META(phi::ScatterNdAddGradInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(ScatterNdAddGradNoNeedBufferVarInferer, - "Updates"); - -template -class SeluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("selu_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SeluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "Out"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(selu_grad, - SeluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class GraphSendUvGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("graph_send_uv_grad"); - - grad_op->SetInput("x", this->Input("x")); - grad_op->SetInput("y", this->Input("y")); - grad_op->SetInput("src_index", this->Input("src_index")); - grad_op->SetInput("dst_index", this->Input("dst_index")); - grad_op->SetInput(GradVarName("out"), this->OutputGrad("out")); - - grad_op->SetOutput(GradVarName("x"), this->InputGrad("x")); - grad_op->SetOutput(GradVarName("y"), this->InputGrad("y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class GraphSendUvGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = - framework::OperatorWithKernel::IndicateVarDataType(ctx, "x"); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(graph_send_uv_grad, - GraphSendUvGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class SigmoidGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sigmoid_grad_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput("fwd_grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("Out"), this->InputGrad("Out")); - grad_op->SetOutput(GradVarName("fwd_grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SigmoidGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sigmoid_grad_grad, - SigmoidGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(SigmoidGradGradInplaceInferer, - {GradVarName("grad_x"), - GradVarName("fwd_grad_out")}); - -template -class SigmoidGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sigmoid_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SigmoidGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sigmoid_grad, - SigmoidGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SigmoidGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SigmoidTripleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sigmoid_triple_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput("fwd_grad_out", this->Input("fwd_grad_out")); - grad_op->SetInput("grad_grad_x", this->Input(GradVarName("grad_x"))); - grad_op->SetInput(GradVarName("grad_out"), - this->OutputGrad(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_grad_out"), - this->OutputGrad(GradVarName("fwd_grad_out"))); - - grad_op->SetOutput(GradVarName("Out"), this->InputGrad("Out")); - grad_op->SetOutput(GradVarName("fwd_grad_out"), - this->InputGrad("fwd_grad_out")); - grad_op->SetOutput(GradVarName("grad_grad_x"), - this->InputGrad(GradVarName("grad_x"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SigmoidTripleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sigmoid_triple_grad, - SigmoidTripleGradInferShapeFunctor, - PD_INFER_META(phi::GeneralTernaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(SigmoidTripleGradInplaceInferer, - {"grad_grad_x", GradVarName("fwd_grad_out")}); - -template -class SiluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("silu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SiluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(silu_grad, - SiluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SiluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SinDoubleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sin_double_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SinDoubleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sin_double_grad, - SinDoubleGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(SinDoubleGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class SinGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sin_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SinGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sin_grad, - SinGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SinGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SinTripleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sin_triple_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out_forward", this->Input("grad_out")); - grad_op->SetInput("grad_x_grad_forward", - this->Input(GradVarName("grad_x"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - grad_op->SetInput(GradVarName("grad_out_grad"), - this->OutputGrad(GradVarName("grad_out"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out_forward"), - this->InputGrad("grad_out")); - grad_op->SetOutput(GradVarName("grad_x_grad_forward"), - this->InputGrad(GradVarName("grad_x"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SinTripleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sin_triple_grad, - SinTripleGradInferShapeFunctor, - PD_INFER_META(phi::GeneralTernaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(SinTripleGradInplaceInferer, - {"grad_x_grad_forward", - GradVarName("grad_out_forward")}); - -template -class SinhGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sinh_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SinhGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sinh_grad, - SinhGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SinhGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SoftplusGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("softplus_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SoftplusGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(softplus_grad, - SoftplusGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SoftplusGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SoftshrinkGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("softshrink_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SoftshrinkGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(softshrink_grad, - SoftshrinkGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SoftshrinkGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SoftsignGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("softsign_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SoftsignGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(softsign_grad, - SoftsignGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SoftsignGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SolveGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("solve_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SolveGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(solve_grad, - SolveGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -template -class SqrtGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sqrt_grad_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput("grad_x", this->Output(GradVarName("X"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("Out"), this->InputGrad("Out")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SqrtGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sqrt_grad_grad, - SqrtGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(SqrtGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class SqrtGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("sqrt_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SqrtGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(sqrt_grad, - SqrtGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SqrtGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SquareGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("square_grad_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SquareGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(square_grad_grad, - SquareGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(SquareGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class SquareGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("square_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SquareGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(square_grad, - SquareGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(SquareGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class Squeeze2DoubleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("squeeze2"); - - grad_op->SetInput("X", this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput("Out", this->InputGrad(GradVarName("Out"))); - grad_op->SetOutput("XShape", this->Input("XShape")); - - grad_op->SetAttr("axes", this->GetAttr("axes")); - } -}; - -template -class Squeeze2GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("squeeze2_grad"); - - grad_op->SetInput("XShape", this->Output("XShape")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class Squeeze2GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(squeeze2_grad, - Squeeze2GradInferShapeFunctor, - PD_INFER_META(phi::KernelWithXShapeInferMeta)); -DECLARE_INPLACE_OP_INFERER(Squeeze2GradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class SvdGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("svd_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("U", this->Output("U")); - grad_op->SetInput("VH", this->Output("VH")); - grad_op->SetInput("S", this->Output("S")); - grad_op->SetInput(GradVarName("U"), this->OutputGrad("U")); - grad_op->SetInput(GradVarName("VH"), this->OutputGrad("VH")); - grad_op->SetInput(GradVarName("S"), this->OutputGrad("S")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class SvdGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(svd_grad, - SvdGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class TakeAlongAxisGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("take_along_axis_grad"); - - grad_op->SetInput("Input", this->Input("Input")); - grad_op->SetInput("Index", this->Input("Index")); - grad_op->SetInput(GradVarName("Result"), this->OutputGrad("Result")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TakeAlongAxisGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(take_along_axis_grad, - TakeAlongAxisGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class TanGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("tan_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TanGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tan_grad, - TanGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(TanGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class TanhGradGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("tanh_grad_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput("grad_out", this->Input(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_x"), - this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput(GradVarName("Out"), this->InputGrad("Out")); - grad_op->SetOutput(GradVarName("grad_out"), - this->InputGrad(GradVarName("Out"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TanhGradGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tanh_grad_grad, - TanhGradGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(TanhGradGradInplaceInferer, - {GradVarName("grad_x"), GradVarName("grad_out")}); - -template -class TanhGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("tanh_grad"); - - grad_op->SetInput("Out", this->Output("Out")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TanhGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tanh_grad, - TanhGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(TanhGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class TanhShrinkGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("tanh_shrink_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TanhShrinkGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tanh_shrink_grad, - TanhShrinkGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(TanhShrinkGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class TanhTripleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("tanh_triple_grad"); - - grad_op->SetInput("Out", this->Input("Out")); - grad_op->SetInput("grad_out_forward", this->Input("grad_out")); - grad_op->SetInput("grad_x_grad_forward", - this->Input(GradVarName("grad_x"))); - grad_op->SetInput(GradVarName("grad_out_new"), - this->OutputGrad(GradVarName("Out"))); - grad_op->SetInput(GradVarName("grad_out_grad"), - this->OutputGrad(GradVarName("grad_out"))); - - grad_op->SetOutput(GradVarName("Out"), this->InputGrad("Out")); - grad_op->SetOutput(GradVarName("grad_out_forward"), - this->InputGrad("grad_out")); - grad_op->SetOutput(GradVarName("grad_x_grad_forward"), - this->InputGrad(GradVarName("grad_x"))); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TanhTripleGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(tanh_triple_grad, - TanhTripleGradInferShapeFunctor, - PD_INFER_META(phi::GeneralTernaryGradInferMeta)); -DECLARE_INPLACE_OP_INFERER(TanhTripleGradInplaceInferer, - {"grad_x_grad_forward", - GradVarName("grad_out_forward")}); - -template -class ThresholdedReluGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("thresholded_relu_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class ThresholdedReluGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(thresholded_relu_grad, - ThresholdedReluGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); -DECLARE_INPLACE_OP_INFERER(ThresholdedReluGradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class TopKV2GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("top_k_v2_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Indices", this->Output("Indices")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - if (this->HasInput("K")) { - grad_op->SetInput("K", this->Input("K")); - } - } -}; - -class TopKV2GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(top_k_v2_grad, - TopKV2GradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class TraceGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("trace_grad"); - - grad_op->SetInput("Input", this->Input("Input")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("Input"), this->InputGrad("Input")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TraceGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(trace_grad, - TraceGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(TraceGradNoNeedBufferVarInferer, "Input"); - -template -class TruncGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("trunc_grad"); - - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class TruncGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(trunc_grad, - TruncGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -template -class UnfoldGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("unfold_grad"); - - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput(GradVarName("Y"), this->OutputGrad("Y")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class UnfoldGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Y")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(unfold_grad, - UnfoldGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(UnfoldGradNoNeedBufferVarInferer, "X"); - -template -class Unsqueeze2DoubleGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("unsqueeze2"); - - grad_op->SetInput("X", this->OutputGrad(GradVarName("X"))); - - grad_op->SetOutput("Out", this->InputGrad(GradVarName("Out"))); - grad_op->SetOutput("XShape", this->Input("XShape")); - - grad_op->SetAttr("axes", this->GetAttr("axes")); - } -}; - -template -class Unsqueeze2GradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("unsqueeze2_grad"); - - grad_op->SetInput("XShape", this->Output("XShape")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - if (this->HasInput("AxesTensor")) { - grad_op->SetInput("AxesTensor", this->Input("AxesTensor")); - } - if (this->HasInput("AxesTensorList")) { - grad_op->SetInput("AxesTensorList", this->Input("AxesTensorList")); - } - } -}; - -class Unsqueeze2GradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; - - protected: - phi::KernelKey GetExpectedKernelType( - const framework::ExecutionContext& ctx) const override { - auto data_type = framework::OperatorWithKernel::IndicateVarDataType( - ctx, GradVarName("Out")); - return phi::KernelKey(data_type, ctx.GetPlace()); - } -}; - -DECLARE_INFER_SHAPE_FUNCTOR(unsqueeze2_grad, - Unsqueeze2GradInferShapeFunctor, - PD_INFER_META(phi::KernelWithXShapeInferMeta)); -DECLARE_INPLACE_OP_INFERER(Unsqueeze2GradInplaceInferer, - {GradVarName("Out"), GradVarName("X")}); - -template -class UnstackGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("unstack_grad"); - - grad_op->SetInput(GradVarName("Y"), this->OutputGrad("Y")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class UnstackGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(unstack_grad, - UnstackGradInferShapeFunctor, - PD_INFER_META(phi::UnStackGradInferMeta)); - -template -class WarprnntGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("warprnnt_grad"); - - grad_op->SetInput("input", this->Input("input")); - grad_op->SetInput("input_lengths", this->Input("input_lengths")); - grad_op->SetInput("warprnntgrad", this->Output("warprnntgrad")); - grad_op->SetInput(GradVarName("loss"), this->OutputGrad("loss")); - - grad_op->SetOutput(GradVarName("input"), this->InputGrad("input")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class WarprnntGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(warprnnt_grad, - WarprnntGradInferShapeFunctor, - PD_INFER_META(phi::UnchangedInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(WarprnntGradNoNeedBufferVarInferer, - "input"); - -template -class WhereGradOpMaker : public framework::SingleGradOpMaker { - public: - using framework::SingleGradOpMaker::SingleGradOpMaker; - - protected: - void Apply(GradOpPtr grad_op) const override { - grad_op->SetType("where_grad"); - - grad_op->SetInput("Condition", this->Input("Condition")); - grad_op->SetInput("X", this->Input("X")); - grad_op->SetInput("Y", this->Input("Y")); - grad_op->SetInput(GradVarName("Out"), this->OutputGrad("Out")); - - grad_op->SetOutput(GradVarName("X"), this->InputGrad("X")); - grad_op->SetOutput(GradVarName("Y"), this->InputGrad("Y")); - - grad_op->SetAttrMap(this->Attrs()); - } -}; - -class WhereGradOp : public framework::OperatorWithKernel { - public: - using framework::OperatorWithKernel::OperatorWithKernel; -}; - -DECLARE_INFER_SHAPE_FUNCTOR(where_grad, - WhereGradInferShapeFunctor, - PD_INFER_META(phi::GeneralBinaryGradInferMeta)); - -DECLARE_NO_NEED_BUFFER_VARS_INFERER(WhereGradNoNeedBufferVarInferer, "X", "Y"); - -} // namespace operators -} // namespace paddle - -namespace ops = paddle::operators; -REGISTER_OPERATOR(acos, - ops::AcosOp, - ops::AcosOpMaker, - ops::AcosGradOpMaker, - ops::AcosGradOpMaker, - ops::AcosInferShapeFunctor); - -REGISTER_OPERATOR(acosh, - ops::AcoshOp, - ops::AcoshOpMaker, - ops::AcoshGradOpMaker, - ops::AcoshGradOpMaker, - ops::AcoshInferShapeFunctor); - -REGISTER_OPERATOR(addmm, - ops::AddmmOp, - ops::AddmmOpMaker, - ops::AddmmGradOpMaker, - ops::AddmmGradOpMaker, - ops::AddmmInferShapeFunctor); - -REGISTER_OPERATOR( - allclose, - ops::AllcloseOp, - ops::AllcloseOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AllcloseInferShapeFunctor); - -REGISTER_OP_VERSION(allclose) - .AddCheckpoint( - R"ROC(Upgrade allclose, add two new inputs [Rtol] and [Atol].)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewInput("Rtol", "The added input 'Rtol' is not dispensable.") - .NewInput("Atol", "The added input 'Atol' is not dispensable.")) - .AddCheckpoint( - R"ROC(Delete two float attributes [rtol] and [atol], then add 2 string attributes [atol, rtol]. Don't be surprised. This is because float cannot represent hight-precision floating-point values, and our framework doesn't support the use of double attributes. As a result, string instead of double is used here to represent high-precision floating-point values.)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("rtol", - "The relative tolerance. Default::math:`1e-5` .", - std::string("1e-5")) - .DeleteAttr("rtol", - "The attribute 'rtol' is deleted. The reason why it is " - "deleted is that attributes do not support a float64 " - "value and it is changed to a tensor.") - .NewAttr("atol", - "(string) The absolute tolerance. Default::math:`1e-8` .", - std::string("1e-5")) - .DeleteAttr("atol", - "The attribute 'atol' is deleted. The reason why it is " - "deleted is that attributes do not support a float64 " - "value and it is changed to a tensor.")); - -REGISTER_OPERATOR(angle, - ops::AngleOp, - ops::AngleOpMaker, - ops::AngleGradOpMaker, - ops::AngleGradOpMaker, - ops::AngleInferShapeFunctor); - -REGISTER_OPERATOR(argsort, - ops::ArgsortOp, - ops::ArgsortOpMaker, - ops::ArgsortGradOpMaker, - ops::ArgsortGradOpMaker, - ops::ArgsortInferShapeFunctor); - -REGISTER_OPERATOR(as_complex, - ops::AsComplexOp, - ops::AsComplexOpMaker, - ops::AsComplexGradOpMaker, - ops::AsComplexGradOpMaker, - ops::AsComplexInferShapeFunctor); - -REGISTER_OPERATOR(as_real, - ops::AsRealOp, - ops::AsRealOpMaker, - ops::AsRealGradOpMaker, - ops::AsRealGradOpMaker, - ops::AsRealInferShapeFunctor); - -REGISTER_OPERATOR(asin, - ops::AsinOp, - ops::AsinOpMaker, - ops::AsinGradOpMaker, - ops::AsinGradOpMaker, - ops::AsinInferShapeFunctor); - -REGISTER_OPERATOR(asinh, - ops::AsinhOp, - ops::AsinhOpMaker, - ops::AsinhGradOpMaker, - ops::AsinhGradOpMaker, - ops::AsinhInferShapeFunctor); - -REGISTER_OPERATOR(atan, - ops::AtanOp, - ops::AtanOpMaker, - ops::AtanGradOpMaker, - ops::AtanGradOpMaker, - ops::AtanInferShapeFunctor); - -REGISTER_OPERATOR(atan2, - ops::Atan2Op, - ops::Atan2OpMaker, - ops::Atan2GradOpMaker, - ops::Atan2GradOpMaker, - ops::Atan2InferShapeFunctor); - -REGISTER_OPERATOR(atanh, - ops::AtanhOp, - ops::AtanhOpMaker, - ops::AtanhGradOpMaker, - ops::AtanhGradOpMaker, - ops::AtanhInferShapeFunctor); - -REGISTER_OPERATOR( - bernoulli, - ops::BernoulliOp, - ops::BernoulliOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::BernoulliInferShapeFunctor); - -REGISTER_OPERATOR(bmm, - ops::BmmOp, - ops::BmmOpMaker, - ops::BmmGradOpMaker, - ops::BmmGradOpMaker, - ops::BmmInferShapeFunctor); - -REGISTER_OPERATOR(ceil, - ops::CeilOp, - ops::CeilOpMaker, - ops::CeilGradOpMaker, - ops::CeilGradOpMaker, - ops::CeilInplaceInferer, - ops::CeilInferShapeFunctor); - -REGISTER_OPERATOR(celu, - ops::CeluOp, - ops::CeluOpMaker, - ops::CeluGradOpMaker, - ops::CeluGradOpMaker, - ops::CeluInferShapeFunctor); - -REGISTER_OPERATOR(cholesky, - ops::CholeskyOp, - ops::CholeskyOpMaker, - ops::CholeskyGradOpMaker, - ops::CholeskyGradOpMaker, - ops::CholeskyInferShapeFunctor); - -REGISTER_OPERATOR(cholesky_solve, - ops::CholeskySolveOp, - ops::CholeskySolveOpMaker, - ops::CholeskySolveGradOpMaker, - ops::CholeskySolveGradOpMaker, - ops::CholeskySolveInferShapeFunctor); - -REGISTER_OPERATOR(clip, - ops::ClipOp, - ops::ClipOpMaker, - ops::ClipGradOpMaker, - ops::ClipGradOpMaker, - ops::ClipInplaceInferer, - ops::ClipInferShapeFunctor); - -REGISTER_OP_VERSION(clip).AddCheckpoint( - R"ROC(Upgrade clip add a new input [Min])ROC", - paddle::framework::compatible::OpVersionDesc() - .NewInput("Min", - "Pass the mix, min value as input, not attribute. Min is " - "dispensable.") - .NewInput("Max", - "Pass the mix, min value as input, not attribute. Max is " - "dispensable.")); - -REGISTER_OPERATOR(complex, - ops::ComplexOp, - ops::ComplexOpMaker, - ops::ComplexGradOpMaker, - ops::ComplexGradOpMaker, - ops::ComplexInferShapeFunctor); - -REGISTER_OPERATOR(conj, - ops::ConjOp, - ops::ConjOpMaker, - ops::ConjGradOpMaker, - ops::ConjGradOpMaker, - ops::ConjInferShapeFunctor); - -REGISTER_OPERATOR(cos, - ops::CosOp, - ops::CosOpMaker, - ops::CosGradOpMaker, - ops::CosGradOpMaker, - ops::CosInferShapeFunctor); - -REGISTER_OPERATOR(cosh, - ops::CoshOp, - ops::CoshOpMaker, - ops::CoshGradOpMaker, - ops::CoshGradOpMaker, - ops::CoshInferShapeFunctor); - -REGISTER_OPERATOR(crop_tensor, - ops::CropTensorOp, - ops::CropTensorOpMaker, - ops::CropTensorGradOpMaker, - ops::CropTensorGradOpMaker, - ops::CropTensorInferShapeFunctor); - -REGISTER_OPERATOR(cross, - ops::CrossOp, - ops::CrossOpMaker, - ops::CrossGradOpMaker, - ops::CrossGradOpMaker, - ops::CrossInferShapeFunctor); - -REGISTER_OPERATOR(determinant, - ops::DeterminantOp, - ops::DeterminantOpMaker, - ops::DeterminantGradOpMaker, - ops::DeterminantGradOpMaker, - ops::DeterminantInferShapeFunctor); - -REGISTER_OPERATOR(diag_v2, - ops::DiagV2Op, - ops::DiagV2OpMaker, - ops::DiagV2GradOpMaker, - ops::DiagV2GradOpMaker, - ops::DiagV2InferShapeFunctor); - -REGISTER_OPERATOR( - diag_embed, - ops::DiagEmbedOp, - ops::DiagEmbedOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DiagEmbedInferShapeFunctor); - -REGISTER_OPERATOR(diagonal, - ops::DiagonalOp, - ops::DiagonalOpMaker, - ops::DiagonalGradOpMaker, - ops::DiagonalGradOpMaker, - ops::DiagonalInferShapeFunctor); - -REGISTER_OPERATOR(digamma, - ops::DigammaOp, - ops::DigammaOpMaker, - ops::DigammaGradOpMaker, - ops::DigammaGradOpMaker, - ops::DigammaInferShapeFunctor); - -REGISTER_OPERATOR(dist, - ops::DistOp, - ops::DistOpMaker, - ops::DistGradOpMaker, - ops::DistGradOpMaker, - ops::DistInferShapeFunctor); - -REGISTER_OPERATOR(dot, - ops::DotOp, - ops::DotOpMaker, - ops::DotGradOpMaker, - ops::DotGradOpMaker, - ops::DotInferShapeFunctor); - -REGISTER_OPERATOR(eig, - ops::EigOp, - ops::EigOpMaker, - ops::EigGradOpMaker, - ops::EigGradOpMaker, - ops::EigInferShapeFunctor); - -REGISTER_OPERATOR(eigh, - ops::EighOp, - ops::EighOpMaker, - ops::EighGradOpMaker, - ops::EighGradOpMaker, - ops::EighInferShapeFunctor); - -REGISTER_OPERATOR( - eigvals, - ops::EigvalsOp, - ops::EigvalsOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::EigvalsInferShapeFunctor); - -REGISTER_OPERATOR(elu, - ops::EluOp, - ops::EluOpMaker, - ops::EluGradOpMaker, - ops::EluGradOpMaker, - ops::EluInplaceInferer, - ops::EluInferShapeFunctor); - -REGISTER_OPERATOR( - equal_all, - ops::EqualAllOp, - ops::EqualAllOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::EqualAllInferShapeFunctor); - -REGISTER_OPERATOR(erf, - ops::ErfOp, - ops::ErfOpMaker, - ops::ErfGradOpMaker, - ops::ErfGradOpMaker, - ops::ErfInferShapeFunctor); - -REGISTER_OPERATOR(erfinv, - ops::ErfinvOp, - ops::ErfinvOpMaker, - ops::ErfinvGradOpMaker, - ops::ErfinvGradOpMaker, - ops::ErfinvInplaceInferer, - ops::ErfinvInferShapeFunctor); - -REGISTER_OPERATOR(exp, - ops::ExpOp, - ops::ExpOpMaker, - ops::ExpGradOpMaker, - ops::ExpGradOpMaker, - ops::ExpInplaceInferer, - ops::ExpInferShapeFunctor); - -REGISTER_OPERATOR(expm1, - ops::Expm1Op, - ops::Expm1OpMaker, - ops::Expm1GradOpMaker, - ops::Expm1GradOpMaker, - ops::Expm1InferShapeFunctor); - -REGISTER_OPERATOR(fft_c2c, - ops::FftC2cOp, - ops::FftC2cOpMaker, - ops::FftC2cGradOpMaker, - ops::FftC2cGradOpMaker, - ops::FftC2cInferShapeFunctor); - -REGISTER_OPERATOR(fft_c2r, - ops::FftC2rOp, - ops::FftC2rOpMaker, - ops::FftC2rGradOpMaker, - ops::FftC2rGradOpMaker, - ops::FftC2rInferShapeFunctor); - -REGISTER_OPERATOR(fft_r2c, - ops::FftR2cOp, - ops::FftR2cOpMaker, - ops::FftR2cGradOpMaker, - ops::FftR2cGradOpMaker, - ops::FftR2cInferShapeFunctor); - -REGISTER_OPERATOR(fill_diagonal, - ops::FillDiagonalOp, - ops::FillDiagonalOpMaker, - ops::FillDiagonalGradOpMaker, - ops::FillDiagonalGradOpMaker, - ops::FillDiagonalInplaceInferer, - ops::FillDiagonalInferShapeFunctor); - -REGISTER_OPERATOR( - fill_diagonal_tensor, - ops::FillDiagonalTensorOp, - ops::FillDiagonalTensorOpMaker, - ops::FillDiagonalTensorGradOpMaker, - ops::FillDiagonalTensorGradOpMaker, - ops::FillDiagonalTensorInplaceInferer, - ops::FillDiagonalTensorInferShapeFunctor); - -REGISTER_OPERATOR(flip, - ops::FlipOp, - ops::FlipOpMaker, - ops::FlipGradOpMaker, - ops::FlipGradOpMaker, - ops::FlipInferShapeFunctor); - -REGISTER_OP_VERSION(flip).AddCheckpoint( - R"ROC(Upgrade flip, add new attr [axis] and delete attr [dims])ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("axis", - "The added attr 'axis' doesn't set default value", - paddle::none) - .DeleteAttr("dims", "The attr 'dims' is deleted.")); - -REGISTER_OPERATOR(floor, - ops::FloorOp, - ops::FloorOpMaker, - ops::FloorGradOpMaker, - ops::FloorGradOpMaker, - ops::FloorInplaceInferer, - ops::FloorInferShapeFunctor); - -REGISTER_OPERATOR(fold, - ops::FoldOp, - ops::FoldOpMaker, - ops::FoldGradOpMaker, - ops::FoldGradOpMaker, - ops::FoldInferShapeFunctor); - -REGISTER_OPERATOR(frame, - ops::FrameOp, - ops::FrameOpMaker, - ops::FrameGradOpMaker, - ops::FrameGradOpMaker, - ops::FrameInferShapeFunctor); - -REGISTER_OPERATOR(gather_nd, - ops::GatherNdOp, - ops::GatherNdOpMaker, - ops::GatherNdGradOpMaker, - ops::GatherNdGradOpMaker, - ops::GatherNdInferShapeFunctor); - -REGISTER_OPERATOR( - gather_tree, - ops::GatherTreeOp, - ops::GatherTreeOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::GatherTreeInferShapeFunctor); - -REGISTER_OPERATOR(gelu, - ops::GeluOp, - ops::GeluOpMaker, - ops::GeluGradOpMaker, - ops::GeluGradOpMaker, - ops::GeluInferShapeFunctor); - -REGISTER_OPERATOR(grid_sampler, - ops::GridSamplerOp, - ops::GridSamplerOpMaker, - ops::GridSamplerGradOpMaker, - ops::GridSamplerGradOpMaker, - ops::GridSamplerInferShapeFunctor); - -REGISTER_OP_VERSION(grid_sampler) - .AddCheckpoint(R"ROC(Upgrade grid_sampler add a new attribute [mode])ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "mode", - "In order to specify interpolation mode", - std::string("bilinear"))); - -REGISTER_OPERATOR(gumbel_softmax, - ops::GumbelSoftmaxOp, - ops::GumbelSoftmaxOpMaker, - ops::GumbelSoftmaxGradOpMaker, - ops::GumbelSoftmaxGradOpMaker, - ops::GumbelSoftmaxInferShapeFunctor); - -REGISTER_OPERATOR(hard_shrink, - ops::HardShrinkOp, - ops::HardShrinkOpMaker, - ops::HardShrinkGradOpMaker, - ops::HardShrinkGradOpMaker, - ops::HardShrinkInferShapeFunctor); - -REGISTER_OPERATOR(hard_sigmoid, - ops::HardSigmoidOp, - ops::HardSigmoidOpMaker, - ops::HardSigmoidGradOpMaker, - ops::HardSigmoidGradOpMaker, - ops::HardSigmoidInferShapeFunctor); - -REGISTER_OPERATOR(brelu, - ops::BreluOp, - ops::BreluOpMaker, - ops::BreluGradOpMaker, - ops::BreluGradOpMaker, - ops::BreluInferShapeFunctor); - -REGISTER_OPERATOR( - histogram, - ops::HistogramOp, - ops::HistogramOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::HistogramInferShapeFunctor); - -REGISTER_OPERATOR(imag, - ops::ImagOp, - ops::ImagOpMaker, - ops::ImagGradOpMaker, - ops::ImagGradOpMaker, - ops::ImagInferShapeFunctor); - -REGISTER_OPERATOR(index_sample, - ops::IndexSampleOp, - ops::IndexSampleOpMaker, - ops::IndexSampleGradOpMaker, - ops::IndexSampleGradOpMaker, - ops::IndexSampleInferShapeFunctor); - -REGISTER_OPERATOR(index_select, - ops::IndexSelectOp, - ops::IndexSelectOpMaker, - ops::IndexSelectGradOpMaker, - ops::IndexSelectGradOpMaker, - ops::IndexSelectInferShapeFunctor); - -REGISTER_OPERATOR(inverse, - ops::InverseOp, - ops::InverseOpMaker, - ops::InverseGradOpMaker, - ops::InverseGradOpMaker, - ops::InverseInferShapeFunctor); - -REGISTER_OPERATOR( - is_empty, - ops::IsEmptyOp, - ops::IsEmptyOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IsEmptyInferShapeFunctor); - -REGISTER_OPERATOR( - isclose, - ops::IscloseOp, - ops::IscloseOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IscloseInferShapeFunctor); - -REGISTER_OPERATOR( - isfinite_v2, - ops::IsfiniteV2Op, - ops::IsfiniteV2OpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IsfiniteV2InferShapeFunctor); - -REGISTER_OPERATOR( - isinf_v2, - ops::IsinfV2Op, - ops::IsinfV2OpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IsinfV2InferShapeFunctor); - -REGISTER_OPERATOR( - isnan_v2, - ops::IsnanV2Op, - ops::IsnanV2OpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IsnanV2InferShapeFunctor); - -REGISTER_OPERATOR(kthvalue, - ops::KthvalueOp, - ops::KthvalueOpMaker, - ops::KthvalueGradOpMaker, - ops::KthvalueGradOpMaker, - ops::KthvalueInferShapeFunctor); - -REGISTER_OPERATOR(label_smooth, - ops::LabelSmoothOp, - ops::LabelSmoothOpMaker, - ops::LabelSmoothGradOpMaker, - ops::LabelSmoothGradOpMaker, - ops::LabelSmoothInferShapeFunctor); - -REGISTER_OPERATOR(leaky_relu, - ops::LeakyReluOp, - ops::LeakyReluOpMaker, - ops::LeakyReluGradOpMaker, - ops::LeakyReluGradOpMaker, - ops::LeakyReluInferShapeFunctor); - -REGISTER_OPERATOR(lerp, - ops::LerpOp, - ops::LerpOpMaker, - ops::LerpGradOpMaker, - ops::LerpGradOpMaker, - ops::LerpInplaceInferer, - ops::LerpInferShapeFunctor); - -REGISTER_OPERATOR(lgamma, - ops::LgammaOp, - ops::LgammaOpMaker, - ops::LgammaGradOpMaker, - ops::LgammaGradOpMaker, - ops::LgammaInferShapeFunctor); - -REGISTER_OPERATOR(log, - ops::LogOp, - ops::LogOpMaker, - ops::LogGradOpMaker, - ops::LogGradOpMaker, - ops::LogInferShapeFunctor); - -REGISTER_OPERATOR(log10, - ops::Log10Op, - ops::Log10OpMaker, - ops::Log10GradOpMaker, - ops::Log10GradOpMaker, - ops::Log10InferShapeFunctor); - -REGISTER_OPERATOR(log1p, - ops::Log1pOp, - ops::Log1pOpMaker, - ops::Log1pGradOpMaker, - ops::Log1pGradOpMaker, - ops::Log1pInferShapeFunctor); - -REGISTER_OPERATOR(log2, - ops::Log2Op, - ops::Log2OpMaker, - ops::Log2GradOpMaker, - ops::Log2GradOpMaker, - ops::Log2InferShapeFunctor); - -REGISTER_OPERATOR(log_loss, - ops::LogLossOp, - ops::LogLossOpMaker, - ops::LogLossGradOpMaker, - ops::LogLossGradOpMaker, - ops::LogLossInferShapeFunctor); - -REGISTER_OPERATOR(logit, - ops::LogitOp, - ops::LogitOpMaker, - ops::LogitGradOpMaker, - ops::LogitGradOpMaker, - ops::LogitInferShapeFunctor); - -REGISTER_OPERATOR(logsigmoid, - ops::LogsigmoidOp, - ops::LogsigmoidOpMaker, - ops::LogsigmoidGradOpMaker, - ops::LogsigmoidGradOpMaker, - ops::LogsigmoidInferShapeFunctor); - -REGISTER_OPERATOR(lu_unpack, - ops::LuUnpackOp, - ops::LuUnpackOpMaker, - ops::LuUnpackGradOpMaker, - ops::LuUnpackGradOpMaker, - ops::LuUnpackInferShapeFunctor); - -REGISTER_OPERATOR(masked_select, - ops::MaskedSelectOp, - ops::MaskedSelectOpMaker, - ops::MaskedSelectGradOpMaker, - ops::MaskedSelectGradOpMaker, - ops::MaskedSelectInferShapeFunctor); - -REGISTER_OPERATOR(matrix_power, - ops::MatrixPowerOp, - ops::MatrixPowerOpMaker, - ops::MatrixPowerGradOpMaker, - ops::MatrixPowerGradOpMaker, - ops::MatrixPowerInferShapeFunctor); - -REGISTER_OPERATOR(maxout, - ops::MaxoutOp, - ops::MaxoutOpMaker, - ops::MaxoutGradOpMaker, - ops::MaxoutGradOpMaker, - ops::MaxoutInferShapeFunctor); - -REGISTER_OPERATOR(mode, - ops::ModeOp, - ops::ModeOpMaker, - ops::ModeGradOpMaker, - ops::ModeGradOpMaker, - ops::ModeInferShapeFunctor); - -REGISTER_OPERATOR( - multinomial, - ops::MultinomialOp, - ops::MultinomialOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::MultinomialInferShapeFunctor); - -REGISTER_OPERATOR(mv, - ops::MvOp, - ops::MvOpMaker, - ops::MvGradOpMaker, - ops::MvGradOpMaker, - ops::MvInferShapeFunctor); - -REGISTER_OPERATOR(nll_loss, - ops::NllLossOp, - ops::NllLossOpMaker, - ops::NllLossGradOpMaker, - ops::NllLossGradOpMaker, - ops::NllLossInferShapeFunctor); - -REGISTER_OPERATOR( - npu_identity, - ops::NpuIdentityOp, - ops::NpuIdentityOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::NpuIdentityInferShapeFunctor); - -REGISTER_OPERATOR(overlap_add, - ops::OverlapAddOp, - ops::OverlapAddOpMaker, - ops::OverlapAddGradOpMaker, - ops::OverlapAddGradOpMaker, - ops::OverlapAddInferShapeFunctor); - -REGISTER_OPERATOR(pixel_shuffle, - ops::PixelShuffleOp, - ops::PixelShuffleOpMaker, - ops::PixelShuffleGradOpMaker, - ops::PixelShuffleGradOpMaker, - ops::PixelShuffleInferShapeFunctor); - -REGISTER_OP_VERSION(pixel_shuffle) - .AddCheckpoint( - R"ROC(Compatible upgrade of pixel_shuffle, add a new attribute [data_format])ROC", - paddle::framework::compatible::OpVersionDesc().NewAttr( - "None", "Specify the data format of the input data", true)); - -REGISTER_OPERATOR(poisson, - ops::PoissonOp, - ops::PoissonOpMaker, - ops::PoissonGradOpMaker, - ops::PoissonGradOpMaker, - ops::PoissonInferShapeFunctor); - -REGISTER_OPERATOR(put_along_axis, - ops::PutAlongAxisOp, - ops::PutAlongAxisOpMaker, - ops::PutAlongAxisGradOpMaker, - ops::PutAlongAxisGradOpMaker, - ops::PutAlongAxisInplaceInferer, - ops::PutAlongAxisInferShapeFunctor); - -REGISTER_OPERATOR(qr, - ops::QrOp, - ops::QrOpMaker, - ops::QrGradOpMaker, - ops::QrGradOpMaker, - ops::QrInferShapeFunctor); - -REGISTER_OPERATOR(real, - ops::RealOp, - ops::RealOpMaker, - ops::RealGradOpMaker, - ops::RealGradOpMaker, - ops::RealInferShapeFunctor); - -REGISTER_OPERATOR(reciprocal, - ops::ReciprocalOp, - ops::ReciprocalOpMaker, - ops::ReciprocalGradOpMaker, - ops::ReciprocalGradOpMaker, - ops::ReciprocalInplaceInferer, - ops::ReciprocalInferShapeFunctor); - -REGISTER_OPERATOR(relu, - ops::ReluOp, - ops::ReluOpMaker, - ops::ReluGradOpMaker, - ops::ReluGradOpMaker, - ops::ReluInplaceInferer, - ops::ReluInferShapeFunctor); - -REGISTER_OPERATOR(renorm, - ops::RenormOp, - ops::RenormOpMaker, - ops::RenormGradOpMaker, - ops::RenormGradOpMaker, - ops::RenormInferShapeFunctor); - -REGISTER_OPERATOR(roll, - ops::RollOp, - ops::RollOpMaker, - ops::RollGradOpMaker, - ops::RollGradOpMaker, - ops::RollInferShapeFunctor); - -REGISTER_OP_VERSION(roll) - .AddCheckpoint( - R"ROC(Upgrade roll add 1 attribute [axis], delete 1 attribute[dims].)ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("axis", - "Axis along which to roll. It must have the same size " - "with shifts, or size = 0.", - std::vector()) - .DeleteAttr("dims", - "Dims along which to roll. It must have the same size " - "with shifts, or size = 0")) - .AddCheckpoint( - R"ROC(Upgrade roll add a dispensable input "ShiftsTensor")ROC", - paddle::framework::compatible::OpVersionDesc().NewInput( - "ShiftsTensor", - "The number of places by which the elements of the tensor are " - "shifted.")); - -REGISTER_OPERATOR(round, - ops::RoundOp, - ops::RoundOpMaker, - ops::RoundGradOpMaker, - ops::RoundGradOpMaker, - ops::RoundInplaceInferer, - ops::RoundInferShapeFunctor); - -REGISTER_OPERATOR(rsqrt, - ops::RsqrtOp, - ops::RsqrtOpMaker, - ops::RsqrtGradOpMaker, - ops::RsqrtGradOpMaker, - ops::RsqrtInplaceInferer, - ops::RsqrtInferShapeFunctor); - -REGISTER_OPERATOR(scatter, - ops::ScatterOp, - ops::ScatterOpMaker, - ops::ScatterGradOpMaker, - ops::ScatterGradOpMaker, - ops::ScatterInplaceInferer, - ops::ScatterInferShapeFunctor); - -REGISTER_OPERATOR(scatter_nd_add, - ops::ScatterNdAddOp, - ops::ScatterNdAddOpMaker, - ops::ScatterNdAddGradOpMaker, - ops::ScatterNdAddGradOpMaker, - ops::ScatterNdAddInferShapeFunctor); - -REGISTER_OPERATOR( - searchsorted, - ops::SearchsortedOp, - ops::SearchsortedOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SearchsortedInferShapeFunctor); - -REGISTER_OPERATOR(selu, - ops::SeluOp, - ops::SeluOpMaker, - ops::SeluGradOpMaker, - ops::SeluGradOpMaker, - ops::SeluInferShapeFunctor); - -REGISTER_OPERATOR(graph_send_uv, - ops::GraphSendUvOp, - ops::GraphSendUvOpMaker, - ops::GraphSendUvGradOpMaker, - ops::GraphSendUvGradOpMaker, - ops::GraphSendUvInferShapeFunctor); - -REGISTER_OPERATOR( - shard_index, - ops::ShardIndexOp, - ops::ShardIndexOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ShardIndexInferShapeFunctor); - -REGISTER_OPERATOR(sigmoid, - ops::SigmoidOp, - ops::SigmoidOpMaker, - ops::SigmoidGradOpMaker, - ops::SigmoidGradOpMaker, - ops::SigmoidInferShapeFunctor); - -REGISTER_OPERATOR(silu, - ops::SiluOp, - ops::SiluOpMaker, - ops::SiluGradOpMaker, - ops::SiluGradOpMaker, - ops::SiluInferShapeFunctor); - -REGISTER_OPERATOR(sin, - ops::SinOp, - ops::SinOpMaker, - ops::SinGradOpMaker, - ops::SinGradOpMaker, - ops::SinInferShapeFunctor); - -REGISTER_OPERATOR(sinh, - ops::SinhOp, - ops::SinhOpMaker, - ops::SinhGradOpMaker, - ops::SinhGradOpMaker, - ops::SinhInferShapeFunctor); - -REGISTER_OPERATOR(softplus, - ops::SoftplusOp, - ops::SoftplusOpMaker, - ops::SoftplusGradOpMaker, - ops::SoftplusGradOpMaker, - ops::SoftplusInferShapeFunctor); - -REGISTER_OPERATOR(softshrink, - ops::SoftshrinkOp, - ops::SoftshrinkOpMaker, - ops::SoftshrinkGradOpMaker, - ops::SoftshrinkGradOpMaker, - ops::SoftshrinkInferShapeFunctor); - -REGISTER_OPERATOR(softsign, - ops::SoftsignOp, - ops::SoftsignOpMaker, - ops::SoftsignGradOpMaker, - ops::SoftsignGradOpMaker, - ops::SoftsignInferShapeFunctor); - -REGISTER_OPERATOR(solve, - ops::SolveOp, - ops::SolveOpMaker, - ops::SolveGradOpMaker, - ops::SolveGradOpMaker, - ops::SolveInferShapeFunctor); - -REGISTER_OPERATOR(sqrt, - ops::SqrtOp, - ops::SqrtOpMaker, - ops::SqrtGradOpMaker, - ops::SqrtGradOpMaker, - ops::SqrtInplaceInferer, - ops::SqrtInferShapeFunctor); - -REGISTER_OPERATOR(square, - ops::SquareOp, - ops::SquareOpMaker, - ops::SquareGradOpMaker, - ops::SquareGradOpMaker, - ops::SquareInferShapeFunctor); - -REGISTER_OPERATOR(squeeze2, - ops::Squeeze2Op, - ops::Squeeze2OpMaker, - ops::Squeeze2GradOpMaker, - ops::Squeeze2GradOpMaker, - ops::Squeeze2InplaceInferer, - ops::Squeeze2InferShapeFunctor); - -REGISTER_OPERATOR(svd, - ops::SvdOp, - ops::SvdOpMaker, - ops::SvdGradOpMaker, - ops::SvdGradOpMaker, - ops::SvdInferShapeFunctor); - -REGISTER_OPERATOR(take_along_axis, - ops::TakeAlongAxisOp, - ops::TakeAlongAxisOpMaker, - ops::TakeAlongAxisGradOpMaker, - ops::TakeAlongAxisGradOpMaker, - ops::TakeAlongAxisInferShapeFunctor); - -REGISTER_OPERATOR(tan, - ops::TanOp, - ops::TanOpMaker, - ops::TanGradOpMaker, - ops::TanGradOpMaker, - ops::TanInferShapeFunctor); - -REGISTER_OPERATOR(tanh, - ops::TanhOp, - ops::TanhOpMaker, - ops::TanhGradOpMaker, - ops::TanhGradOpMaker, - ops::TanhInplaceInferer, - ops::TanhCompositeGradOpMaker, - ops::TanhInferShapeFunctor); - -REGISTER_OPERATOR(tanh_shrink, - ops::TanhShrinkOp, - ops::TanhShrinkOpMaker, - ops::TanhShrinkGradOpMaker, - ops::TanhShrinkGradOpMaker, - ops::TanhShrinkInferShapeFunctor); - -REGISTER_OPERATOR(thresholded_relu, - ops::ThresholdedReluOp, - ops::ThresholdedReluOpMaker, - ops::ThresholdedReluGradOpMaker, - ops::ThresholdedReluGradOpMaker, - ops::ThresholdedReluInferShapeFunctor); - -REGISTER_OPERATOR(top_k_v2, - ops::TopKV2Op, - ops::TopKV2OpMaker, - ops::TopKV2GradOpMaker, - ops::TopKV2GradOpMaker, - ops::TopKV2InferShapeFunctor); - -REGISTER_OPERATOR(trace, - ops::TraceOp, - ops::TraceOpMaker, - ops::TraceGradOpMaker, - ops::TraceGradOpMaker, - ops::TraceInferShapeFunctor); - -REGISTER_OP_VERSION(trace).AddCheckpoint( - R"ROC(Upgrade trace add a new attribute [axis2])ROC", - paddle::framework::compatible::OpVersionDesc() - .NewAttr("axis1", - "The added attribute 'axis1' is not yet registered.", - std::vector{0.0f}) - .NewAttr("None", - "The added attribute 'axis2' is not yet registered.", - std::vector{1.0f}) - .DeleteAttr("dim1", - "The attribute 'dim1' is not recommend according to the " - "specification 2.0.") - .DeleteAttr("dim2", - "The attribute 'dim2' is not recommend according to the " - "specification 2.0.")); - -REGISTER_OPERATOR(trunc, - ops::TruncOp, - ops::TruncOpMaker, - ops::TruncGradOpMaker, - ops::TruncGradOpMaker, - ops::TruncInferShapeFunctor); - -REGISTER_OPERATOR(unfold, - ops::UnfoldOp, - ops::UnfoldOpMaker, - ops::UnfoldGradOpMaker, - ops::UnfoldGradOpMaker, - ops::UnfoldInferShapeFunctor); - -REGISTER_OPERATOR(unsqueeze2, - ops::Unsqueeze2Op, - ops::Unsqueeze2OpMaker, - ops::Unsqueeze2GradOpMaker, - ops::Unsqueeze2GradOpMaker, - ops::Unsqueeze2InplaceInferer, - ops::Unsqueeze2InferShapeFunctor); - -REGISTER_OPERATOR(unstack, - ops::UnstackOp, - ops::UnstackOpMaker, - ops::UnstackGradOpMaker, - ops::UnstackGradOpMaker, - ops::UnstackInferShapeFunctor); - -REGISTER_OPERATOR( - viterbi_decode, - ops::ViterbiDecodeOp, - ops::ViterbiDecodeOpMaker, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ViterbiDecodeInferShapeFunctor); - -REGISTER_OPERATOR(warprnnt, - ops::WarprnntOp, - ops::WarprnntOpMaker, - ops::WarprnntGradOpMaker, - ops::WarprnntGradOpMaker, - ops::WarprnntInferShapeFunctor); - -REGISTER_OPERATOR(where, - ops::WhereOp, - ops::WhereOpMaker, - ops::WhereGradOpMaker, - ops::WhereGradOpMaker, - ops::WhereInferShapeFunctor); - -REGISTER_OPERATOR( - acos_grad, - ops::AcosGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AcosGradInplaceInferer, - ops::AcosGradInferShapeFunctor); - -REGISTER_OPERATOR( - acosh_grad, - ops::AcoshGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AcoshGradInplaceInferer, - ops::AcoshGradInferShapeFunctor); - -REGISTER_OPERATOR( - addmm_grad, - ops::AddmmGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AddmmGradInferShapeFunctor); - -REGISTER_OPERATOR( - angle_grad, - ops::AngleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AngleGradInferShapeFunctor); - -REGISTER_OPERATOR( - argsort_grad, - ops::ArgsortGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ArgsortGradNoNeedBufferVarInferer, - ops::ArgsortGradInferShapeFunctor); - -REGISTER_OPERATOR( - asin_grad, - ops::AsinGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AsinGradInplaceInferer, - ops::AsinGradInferShapeFunctor); - -REGISTER_OPERATOR( - asinh_grad, - ops::AsinhGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AsinhGradInplaceInferer, - ops::AsinhGradInferShapeFunctor); - -REGISTER_OPERATOR( - atan2_grad, - ops::Atan2GradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::Atan2GradInferShapeFunctor); - -REGISTER_OPERATOR( - atan_grad, - ops::AtanGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AtanGradInplaceInferer, - ops::AtanGradInferShapeFunctor); - -REGISTER_OPERATOR( - atanh_grad, - ops::AtanhGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::AtanhGradInplaceInferer, - ops::AtanhGradInferShapeFunctor); - -REGISTER_OPERATOR( - bmm_grad, - ops::BmmGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::BmmGradInferShapeFunctor); - -REGISTER_OPERATOR( - ceil_grad, - ops::CeilGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CeilGradInplaceInferer, - ops::CeilGradInferShapeFunctor); - -REGISTER_OPERATOR( - celu_grad_grad, - ops::CeluGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CeluGradGradInplaceInferer, - ops::CeluGradGradInferShapeFunctor); - -REGISTER_OPERATOR(celu_grad, - ops::CeluGradOp, - ops::CeluGradGradOpMaker, - ops::CeluGradGradOpMaker, - ops::CeluGradInplaceInferer, - ops::CeluGradInferShapeFunctor); - -REGISTER_OPERATOR( - cholesky_grad, - ops::CholeskyGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CholeskyGradInferShapeFunctor); - -REGISTER_OPERATOR( - cholesky_solve_grad, - ops::CholeskySolveGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CholeskySolveGradInferShapeFunctor); - -REGISTER_OPERATOR( - clip_double_grad, - ops::ClipDoubleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ClipDoubleGradInferShapeFunctor); - -REGISTER_OPERATOR(clip_grad, - ops::ClipGradOp, - ops::ClipDoubleGradOpMaker, - ops::ClipDoubleGradOpMaker, - ops::ClipGradInplaceInferer, - ops::ClipGradInferShapeFunctor); - -REGISTER_OPERATOR( - complex_grad, - ops::ComplexGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ComplexGradInferShapeFunctor); - -REGISTER_OPERATOR(cos_double_grad, - ops::CosDoubleGradOp, - ops::CosTripleGradOpMaker, - ops::CosTripleGradOpMaker, - ops::CosDoubleGradInplaceInferer, - ops::CosDoubleGradInferShapeFunctor); - -REGISTER_OPERATOR(cos_grad, - ops::CosGradOp, - ops::CosDoubleGradOpMaker, - ops::CosDoubleGradOpMaker, - ops::CosGradInplaceInferer, - ops::CosGradInferShapeFunctor); - -REGISTER_OPERATOR( - cos_triple_grad, - ops::CosTripleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CosTripleGradInplaceInferer, - ops::CosTripleGradInferShapeFunctor); - -REGISTER_OPERATOR( - cosh_grad, - ops::CoshGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CoshGradInplaceInferer, - ops::CoshGradInferShapeFunctor); - -REGISTER_OPERATOR( - crop_tensor_grad, - ops::CropTensorGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CropTensorGradInferShapeFunctor); - -REGISTER_OPERATOR( - cross_grad, - ops::CrossGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::CrossGradInferShapeFunctor); - -REGISTER_OPERATOR( - determinant_grad, - ops::DeterminantGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DeterminantGradInferShapeFunctor); - -REGISTER_OPERATOR( - diag_v2_grad, - ops::DiagV2GradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DiagV2GradNoNeedBufferVarInferer, - ops::DiagV2GradInferShapeFunctor); - -REGISTER_OPERATOR( - diagonal_grad, - ops::DiagonalGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DiagonalGradNoNeedBufferVarInferer, - ops::DiagonalGradInferShapeFunctor); - -REGISTER_OPERATOR( - digamma_grad, - ops::DigammaGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DigammaGradInferShapeFunctor); - -REGISTER_OPERATOR( - dist_grad, - ops::DistGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DistGradInferShapeFunctor); - -REGISTER_OPERATOR( - dot_grad, - ops::DotGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::DotGradInferShapeFunctor); - -REGISTER_OPERATOR( - eig_grad, - ops::EigGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::EigGradInferShapeFunctor); - -REGISTER_OPERATOR( - eigh_grad, - ops::EighGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::EighGradInferShapeFunctor); - -REGISTER_OPERATOR( - elu_grad_grad, - ops::EluGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::EluGradGradInplaceInferer, - ops::EluGradGradInferShapeFunctor); - -REGISTER_OPERATOR(elu_grad, - ops::EluGradOp, - ops::EluGradGradOpMaker, - ops::EluGradGradOpMaker, - ops::EluGradInplaceInferer, - ops::EluGradInferShapeFunctor); - -REGISTER_OPERATOR( - erf_grad, - ops::ErfGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ErfGradInferShapeFunctor); - -REGISTER_OPERATOR( - erfinv_grad, - ops::ErfinvGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ErfinvGradInferShapeFunctor); - -REGISTER_OPERATOR( - exp_grad, - ops::ExpGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ExpGradInplaceInferer, - ops::ExpGradInferShapeFunctor); - -REGISTER_OPERATOR( - expm1_grad, - ops::Expm1GradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::Expm1GradInplaceInferer, - ops::Expm1GradInferShapeFunctor); - -REGISTER_OPERATOR( - fft_c2c_grad, - ops::FftC2cGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FftC2cGradInferShapeFunctor); - -REGISTER_OPERATOR( - fft_c2r_grad, - ops::FftC2rGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FftC2rGradInferShapeFunctor); - -REGISTER_OPERATOR( - fft_r2c_grad, - ops::FftR2cGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FftR2cGradNoNeedBufferVarInferer, - ops::FftR2cGradInferShapeFunctor); - -REGISTER_OPERATOR( - fill_diagonal_grad, - ops::FillDiagonalGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FillDiagonalGradInferShapeFunctor); - -REGISTER_OPERATOR( - fill_diagonal_tensor_grad, - ops::FillDiagonalTensorGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FillDiagonalTensorGradInplaceInferer, - ops::FillDiagonalTensorGradInferShapeFunctor); - -REGISTER_OPERATOR( - floor_grad, - ops::FloorGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FloorGradInplaceInferer, - ops::FloorGradInferShapeFunctor); - -REGISTER_OPERATOR( - fold_grad, - ops::FoldGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FoldGradNoNeedBufferVarInferer, - ops::FoldGradInferShapeFunctor); - -REGISTER_OPERATOR( - frame_grad, - ops::FrameGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::FrameGradInferShapeFunctor); - -REGISTER_OPERATOR( - gather_nd_grad, - ops::GatherNdGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::GatherNdGradNoNeedBufferVarInferer, - ops::GatherNdGradInferShapeFunctor); - -REGISTER_OPERATOR( - gelu_grad, - ops::GeluGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::GeluGradInferShapeFunctor); - -REGISTER_OPERATOR( - grid_sampler_grad, - ops::GridSamplerGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::GridSamplerGradInferShapeFunctor); - -REGISTER_OPERATOR( - gumbel_softmax_grad, - ops::GumbelSoftmaxGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::GumbelSoftmaxGradInferShapeFunctor); - -REGISTER_OPERATOR( - hard_shrink_grad, - ops::HardShrinkGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::HardShrinkGradInplaceInferer, - ops::HardShrinkGradInferShapeFunctor); - -REGISTER_OPERATOR( - hard_sigmoid_grad, - ops::HardSigmoidGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::HardSigmoidGradInplaceInferer, - ops::HardSigmoidGradInferShapeFunctor); - -REGISTER_OPERATOR( - brelu_grad, - ops::BreluGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::BreluGradInplaceInferer, - ops::BreluGradInferShapeFunctor); - -REGISTER_OPERATOR( - imag_grad, - ops::ImagGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ImagGradInferShapeFunctor); - -REGISTER_OPERATOR( - index_sample_grad, - ops::IndexSampleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IndexSampleGradNoNeedBufferVarInferer, - ops::IndexSampleGradInferShapeFunctor); - -REGISTER_OPERATOR( - index_select_grad, - ops::IndexSelectGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::IndexSelectGradNoNeedBufferVarInferer, - ops::IndexSelectGradInferShapeFunctor); - -REGISTER_OPERATOR( - inverse_grad, - ops::InverseGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::InverseGradInferShapeFunctor); - -REGISTER_OPERATOR( - kthvalue_grad, - ops::KthvalueGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::KthvalueGradInferShapeFunctor); - -REGISTER_OPERATOR( - label_smooth_grad, - ops::LabelSmoothGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LabelSmoothGradInferShapeFunctor); - -REGISTER_OPERATOR( - leaky_relu_grad_grad, - ops::LeakyReluGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LeakyReluGradGradInplaceInferer, - ops::LeakyReluGradGradInferShapeFunctor); - -REGISTER_OPERATOR(leaky_relu_grad, - ops::LeakyReluGradOp, - ops::LeakyReluGradGradOpMaker, - ops::LeakyReluGradGradOpMaker, - ops::LeakyReluGradInplaceInferer, - ops::LeakyReluGradInferShapeFunctor); - -REGISTER_OPERATOR( - lerp_grad, - ops::LerpGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LerpGradInferShapeFunctor); - -REGISTER_OPERATOR( - lgamma_grad, - ops::LgammaGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LgammaGradInferShapeFunctor); - -REGISTER_OPERATOR( - log10_grad, - ops::Log10GradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::Log10GradInplaceInferer, - ops::Log10GradInferShapeFunctor); - -REGISTER_OPERATOR( - log1p_grad, - ops::Log1pGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::Log1pGradInplaceInferer, - ops::Log1pGradInferShapeFunctor); - -REGISTER_OPERATOR( - log2_grad, - ops::Log2GradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::Log2GradInplaceInferer, - ops::Log2GradInferShapeFunctor); - -REGISTER_OPERATOR( - log_grad_grad, - ops::LogGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LogGradGradInplaceInferer, - ops::LogGradGradInferShapeFunctor); - -REGISTER_OPERATOR(log_grad, - ops::LogGradOp, - ops::LogGradGradOpMaker, - ops::LogGradGradOpMaker, - ops::LogGradInplaceInferer, - ops::LogGradInferShapeFunctor); - -REGISTER_OPERATOR( - log_loss_grad, - ops::LogLossGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LogLossGradInferShapeFunctor); - -REGISTER_OPERATOR( - logit_grad, - ops::LogitGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LogitGradInferShapeFunctor); - -REGISTER_OPERATOR( - logsigmoid_grad, - ops::LogsigmoidGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LogsigmoidGradInplaceInferer, - ops::LogsigmoidGradInferShapeFunctor); - -REGISTER_OPERATOR( - lu_unpack_grad, - ops::LuUnpackGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::LuUnpackGradInferShapeFunctor); - -REGISTER_OPERATOR( - masked_select_grad, - ops::MaskedSelectGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::MaskedSelectGradNoNeedBufferVarInferer, - ops::MaskedSelectGradInferShapeFunctor); - -REGISTER_OPERATOR( - matrix_power_grad, - ops::MatrixPowerGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::MatrixPowerGradInferShapeFunctor); - -REGISTER_OPERATOR( - maxout_grad, - ops::MaxoutGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::MaxoutGradInferShapeFunctor); - -REGISTER_OPERATOR( - mode_grad, - ops::ModeGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ModeGradInferShapeFunctor); - -REGISTER_OPERATOR( - mv_grad, - ops::MvGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::MvGradInferShapeFunctor); - -REGISTER_OPERATOR( - nll_loss_grad, - ops::NllLossGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::NllLossGradInferShapeFunctor); - -REGISTER_OPERATOR( - overlap_add_grad, - ops::OverlapAddGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::OverlapAddGradInferShapeFunctor); - -REGISTER_OPERATOR( - pixel_shuffle_grad, - ops::PixelShuffleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::PixelShuffleGradInferShapeFunctor); - -REGISTER_OPERATOR( - poisson_grad, - ops::PoissonGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::PoissonGradInferShapeFunctor); - -REGISTER_OPERATOR( - put_along_axis_grad, - ops::PutAlongAxisGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::PutAlongAxisGradInferShapeFunctor); - -REGISTER_OPERATOR( - qr_grad, - ops::QrGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::QrGradInferShapeFunctor); - -REGISTER_OPERATOR( - real_grad, - ops::RealGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::RealGradInferShapeFunctor); - -REGISTER_OPERATOR( - reciprocal_grad, - ops::ReciprocalGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ReciprocalGradInplaceInferer, - ops::ReciprocalGradInferShapeFunctor); - -REGISTER_OPERATOR( - relu_grad_grad, - ops::ReluGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ReluGradGradInplaceInferer, - ops::ReluGradGradInferShapeFunctor); - -REGISTER_OPERATOR(relu_grad, - ops::ReluGradOp, - ops::ReluGradGradOpMaker, - ops::ReluGradGradOpMaker, - ops::ReluGradInplaceInferer, - ops::ReluGradInferShapeFunctor); - -REGISTER_OPERATOR( - renorm_grad, - ops::RenormGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::RenormGradInferShapeFunctor); - -REGISTER_OPERATOR( - roll_grad, - ops::RollGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::RollGradNoNeedBufferVarInferer, - ops::RollGradInferShapeFunctor); - -REGISTER_OPERATOR( - round_grad, - ops::RoundGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::RoundGradInplaceInferer, - ops::RoundGradInferShapeFunctor); - -REGISTER_OPERATOR( - rsqrt_grad_grad, - ops::RsqrtGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::RsqrtGradGradInplaceInferer, - ops::RsqrtGradGradInferShapeFunctor); - -REGISTER_OPERATOR(rsqrt_grad, - ops::RsqrtGradOp, - ops::RsqrtGradGradOpMaker, - ops::RsqrtGradGradOpMaker, - ops::RsqrtGradInplaceInferer, - ops::RsqrtGradInferShapeFunctor); - -REGISTER_OPERATOR( - scatter_grad, - ops::ScatterGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ScatterGradNoNeedBufferVarInferer, - ops::ScatterGradInferShapeFunctor); - -REGISTER_OPERATOR( - scatter_nd_add_grad, - ops::ScatterNdAddGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ScatterNdAddGradNoNeedBufferVarInferer, - ops::ScatterNdAddGradInferShapeFunctor); - -REGISTER_OPERATOR( - selu_grad, - ops::SeluGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SeluGradInferShapeFunctor); - -REGISTER_OPERATOR( - graph_send_uv_grad, - ops::GraphSendUvGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::GraphSendUvGradInferShapeFunctor); - -REGISTER_OPERATOR(sigmoid_grad_grad, - ops::SigmoidGradGradOp, - ops::SigmoidTripleGradOpMaker, - ops::SigmoidTripleGradOpMaker, - ops::SigmoidGradGradInplaceInferer, - ops::SigmoidGradGradInferShapeFunctor); - -REGISTER_OPERATOR(sigmoid_grad, - ops::SigmoidGradOp, - ops::SigmoidGradGradOpMaker, - ops::SigmoidGradGradOpMaker, - ops::SigmoidGradInplaceInferer, - ops::SigmoidGradInferShapeFunctor); - -REGISTER_OPERATOR( - sigmoid_triple_grad, - ops::SigmoidTripleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SigmoidTripleGradInplaceInferer, - ops::SigmoidTripleGradInferShapeFunctor); - -REGISTER_OPERATOR( - silu_grad, - ops::SiluGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SiluGradInplaceInferer, - ops::SiluGradInferShapeFunctor); - -REGISTER_OPERATOR(sin_double_grad, - ops::SinDoubleGradOp, - ops::SinTripleGradOpMaker, - ops::SinTripleGradOpMaker, - ops::SinDoubleGradInplaceInferer, - ops::SinDoubleGradInferShapeFunctor); - -REGISTER_OPERATOR(sin_grad, - ops::SinGradOp, - ops::SinDoubleGradOpMaker, - ops::SinDoubleGradOpMaker, - ops::SinGradInplaceInferer, - ops::SinGradInferShapeFunctor); - -REGISTER_OPERATOR( - sin_triple_grad, - ops::SinTripleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SinTripleGradInplaceInferer, - ops::SinTripleGradInferShapeFunctor); - -REGISTER_OPERATOR( - sinh_grad, - ops::SinhGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SinhGradInplaceInferer, - ops::SinhGradInferShapeFunctor); - -REGISTER_OPERATOR( - softplus_grad, - ops::SoftplusGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SoftplusGradInplaceInferer, - ops::SoftplusGradInferShapeFunctor); - -REGISTER_OPERATOR( - softshrink_grad, - ops::SoftshrinkGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SoftshrinkGradInplaceInferer, - ops::SoftshrinkGradInferShapeFunctor); - -REGISTER_OPERATOR( - softsign_grad, - ops::SoftsignGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SoftsignGradInplaceInferer, - ops::SoftsignGradInferShapeFunctor); - -REGISTER_OPERATOR( - solve_grad, - ops::SolveGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SolveGradInferShapeFunctor); - -REGISTER_OPERATOR( - sqrt_grad_grad, - ops::SqrtGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SqrtGradGradInplaceInferer, - ops::SqrtGradGradInferShapeFunctor); - -REGISTER_OPERATOR(sqrt_grad, - ops::SqrtGradOp, - ops::SqrtGradGradOpMaker, - ops::SqrtGradGradOpMaker, - ops::SqrtGradInplaceInferer, - ops::SqrtGradInferShapeFunctor); - -REGISTER_OPERATOR( - square_grad_grad, - ops::SquareGradGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SquareGradGradInplaceInferer, - ops::SquareGradGradInferShapeFunctor); - -REGISTER_OPERATOR(square_grad, - ops::SquareGradOp, - ops::SquareGradGradOpMaker, - ops::SquareGradGradOpMaker, - ops::SquareGradInplaceInferer, - ops::SquareGradInferShapeFunctor); - -REGISTER_OPERATOR(squeeze2_grad, - ops::Squeeze2GradOp, - ops::Squeeze2DoubleGradOpMaker, - ops::Squeeze2DoubleGradOpMaker, - ops::Squeeze2GradInplaceInferer, - ops::Squeeze2GradInferShapeFunctor); - -REGISTER_OPERATOR( - svd_grad, - ops::SvdGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::SvdGradInferShapeFunctor); - -REGISTER_OPERATOR( - take_along_axis_grad, - ops::TakeAlongAxisGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TakeAlongAxisGradInferShapeFunctor); - -REGISTER_OPERATOR( - tan_grad, - ops::TanGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TanGradInplaceInferer, - ops::TanGradInferShapeFunctor); - -REGISTER_OPERATOR(tanh_grad_grad, - ops::TanhGradGradOp, - ops::TanhTripleGradOpMaker, - ops::TanhTripleGradOpMaker, - ops::TanhGradGradInplaceInferer, - ops::TanhGradGradInferShapeFunctor); - -REGISTER_OPERATOR(tanh_grad, - ops::TanhGradOp, - ops::TanhGradGradOpMaker, - ops::TanhGradGradOpMaker, - ops::TanhGradInplaceInferer, - ops::TanhGradInferShapeFunctor); - -REGISTER_OPERATOR( - tanh_shrink_grad, - ops::TanhShrinkGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TanhShrinkGradInplaceInferer, - ops::TanhShrinkGradInferShapeFunctor); - -REGISTER_OPERATOR( - tanh_triple_grad, - ops::TanhTripleGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TanhTripleGradInplaceInferer, - ops::TanhTripleGradInferShapeFunctor); - -REGISTER_OPERATOR( - thresholded_relu_grad, - ops::ThresholdedReluGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::ThresholdedReluGradInplaceInferer, - ops::ThresholdedReluGradInferShapeFunctor); - -REGISTER_OPERATOR( - top_k_v2_grad, - ops::TopKV2GradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TopKV2GradInferShapeFunctor); - -REGISTER_OPERATOR( - trace_grad, - ops::TraceGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TraceGradNoNeedBufferVarInferer, - ops::TraceGradInferShapeFunctor); - -REGISTER_OPERATOR( - trunc_grad, - ops::TruncGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::TruncGradInferShapeFunctor); - -REGISTER_OPERATOR( - unfold_grad, - ops::UnfoldGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::UnfoldGradNoNeedBufferVarInferer, - ops::UnfoldGradInferShapeFunctor); - -REGISTER_OPERATOR(unsqueeze2_grad, - ops::Unsqueeze2GradOp, - ops::Unsqueeze2DoubleGradOpMaker, - ops::Unsqueeze2DoubleGradOpMaker, - ops::Unsqueeze2GradInplaceInferer, - ops::Unsqueeze2GradInferShapeFunctor); - -REGISTER_OPERATOR( - unstack_grad, - ops::UnstackGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::UnstackGradInferShapeFunctor); - -REGISTER_OPERATOR( - warprnnt_grad, - ops::WarprnntGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::WarprnntGradNoNeedBufferVarInferer, - ops::WarprnntGradInferShapeFunctor); - -REGISTER_OPERATOR( - where_grad, - ops::WhereGradOp, - paddle::framework::EmptyGradOpMaker, - paddle::framework::EmptyGradOpMaker, - ops::WhereGradNoNeedBufferVarInferer, - ops::WhereGradInferShapeFunctor); diff --git a/paddle/fluid/operators/generator/CMakeLists.txt b/paddle/fluid/operators/generator/CMakeLists.txt index 6eaeaeb101287..759a0fbaae2f5 100644 --- a/paddle/fluid/operators/generator/CMakeLists.txt +++ b/paddle/fluid/operators/generator/CMakeLists.txt @@ -148,15 +148,16 @@ if(${_result}) message(FATAL_ERROR "sparse operator codegen failed, exiting.") endif() -# set(generated_static_files -# "${generated_op_path}" -# "${generated_static_op_path}" -# "${generated_sparse_ops_path}" -# "${generated_argument_mapping_path}" -# "${generated_static_argument_mapping_path}" -# "${generated_sparse_argument_mapping_path}") +set(generated_static_files + "${generated_op_path}" + "${generated_static_op_path}" + "${generated_sparse_ops_path}" + "${generated_argument_mapping_path}" + "${generated_static_argument_mapping_path}" + "${generated_sparse_argument_mapping_path}") set(generated_static_files + "${generated_op_path}" "${generated_static_op_path}" "${generated_sparse_ops_path}" "${generated_argument_mapping_path}" diff --git a/paddle/fluid/operators/generator/filters.py b/paddle/fluid/operators/generator/filters.py index 6a40b936f060f..8efbac1f7e92c 100644 --- a/paddle/fluid/operators/generator/filters.py +++ b/paddle/fluid/operators/generator/filters.py @@ -132,6 +132,17 @@ def to_int_array_tensors_name(attr): return to_pascal_case(attr['name']) + 'TensorList' +def to_composite_grad_opmaker_name(backward_op_name): + words = backward_op_name.split("_") + for i in range(len(words)): + words[i] = words[i].strip() + words[i] = words[i].capitalize() + composite_grad_opmaker_name = words[0] + "Composite" + composite_grad_opmaker_name += "".join(word for word in words[1:]) + composite_grad_opmaker_name += "OpMaker" + return composite_grad_opmaker_name + + def cartesian_prod_attrs(attrs): items = [] for attr in attrs: diff --git a/paddle/fluid/operators/generator/generate_op.py b/paddle/fluid/operators/generator/generate_op.py index a0f4cfacfde38..9bec0c6474d74 100644 --- a/paddle/fluid/operators/generator/generate_op.py +++ b/paddle/fluid/operators/generator/generate_op.py @@ -19,6 +19,7 @@ import yaml from filters import ( cartesian_prod_mapping, + to_composite_grad_opmaker_name, to_input_name, to_int_array_tensor_name, to_int_array_tensors_name, @@ -32,6 +33,7 @@ from parse_utils import to_named_dict from tests import ( is_base_op, + is_composite_op, is_initializer_list, is_scalar, is_vec, @@ -57,7 +59,9 @@ env.filters["to_input_name"] = to_input_name env.filters["to_opmaker_name_cstr"] = to_opmaker_name_cstr env.filters["cartesian_prod_mapping"] = cartesian_prod_mapping +env.filters["to_composite_grad_opmaker_name"] = to_composite_grad_opmaker_name env.tests["base_op"] = is_base_op +env.tests["composite_op"] = is_composite_op env.tests["vec"] = is_vec env.tests["scalar"] = is_scalar env.tests["initializer_list"] = is_initializer_list @@ -153,6 +157,27 @@ def process_int_array(op_item, int_array_configs): ] +def parse_composite_info(ops, backward_ops, backward_op_dict): + for op in ops: + if "backward" in op: + op["phi_backward"] = op["backward"] + for backward_op in backward_ops: + if "backward" in backward_op: + backward_op["phi_backward"] = backward_op["backward"] + for backward_op_name, op_dict in backward_op_dict.items(): + if "composite" not in op_dict: + continue + op_dict["composite"]["phi_inputs"] = [] + op_dict["composite"]["phi_attrs"] = [] + op_dict["composite"]["phi_outputs"] = [] + for input in op_dict["inputs"]: + op_dict["composite"]["phi_inputs"].append(input['name']) + for attr in op_dict["attrs"]: + op_dict["composite"]["phi_attrs"].append(attr['name']) + for output in op_dict["outputs"]: + op_dict["composite"]["phi_outputs"].append(output['name']) + + # replace name of op and params for OpMaker def replace_compat_name(op_fluid_map_list, forward_op_dict, backward_op_dict): def get_phi_and_fluid_op_name(op_item): @@ -178,6 +203,37 @@ def update_grad_args_name(op_args, args_alias_map): ) item['name'] = args_alias_map[item['name'][:-5]] + '_grad' + def add_fluid_info_in_composite(composite_map, args_alias_map): + fluid_input_list = [] + fluid_attr_list = [] + fluid_output_list = [] + # add fluid op inputs + for input in composite_map["phi_inputs"]: + if input in args_alias_map: + fluid_input_list.append(args_alias_map[input]) + else: + fluid_input_list.append(input) + # add fluid op attrs + for attr in composite_map["phi_attrs"]: + if attr in args_alias_map: + fluid_attr_list.append(args_alias_map[attr]) + else: + fluid_attr_list.append(attr) + # add fluid op outputs + for output in composite_map["phi_outputs"]: + if output in args_alias_map: + fluid_output_list.append(args_alias_map[output]) + else: + fluid_output_list.append(output) + + composite_map.update( + { + "fluid_inputs": fluid_input_list, + "fluid_attrs": fluid_attr_list, + "fluid_outputs": fluid_output_list, + } + ) + def get_param_list_alias(param_list, args_map): return [ args_map[param] if param in args_map else param @@ -307,6 +363,15 @@ def update_grad_op_compat_name(grad_op_item, args_name_map): continue backward_op_list = op_args['backward'].split(',') + # add fluid args name in composite map + for backward_op in backward_op_list: + if ( + "composite" + in backward_op_dict[backward_op.split('(')[0].strip()] + ): + add_fluid_info_in_composite( + backward_op_dict[backward_op]["composite"], args_map + ) _, bw_op_name = get_phi_and_fluid_op_name(backward_op_list[0]) forward_op_item['backward'] = bw_op_name backward_op_item['op_name'] = bw_op_name @@ -406,12 +471,10 @@ def main( ops = yaml.safe_load(f) ops = [restruct_io(op) for op in ops] forward_op_dict = to_named_dict(ops) - with open(backward_yaml_path, "rt") as f: backward_ops = yaml.safe_load(f) backward_ops = [restruct_io(op) for op in backward_ops] backward_op_dict = to_named_dict(backward_ops) - with open(op_version_yaml_path, "rt") as f: op_versions = yaml.safe_load(f) # add op version info into op @@ -426,6 +489,8 @@ def main( for bw_op in backward_ops: bw_op['op_name'] = bw_op['name'] + parse_composite_info(ops, backward_ops, backward_op_dict) + replace_compat_name(op_fluid_map_list, forward_op_dict, backward_op_dict) # prepare for invoke case @@ -442,21 +507,21 @@ def main( op_dict = {} op_dict.update(forward_op_dict) op_dict.update(backward_op_dict) - if len(ops) == 0 and len(backward_ops) == 0: if os.path.isfile(output_op_path): os.remove(output_op_path) if os.path.isfile(output_arg_map_path): os.remove(output_arg_map_path) return - op_template = env.get_template('op.c.j2') with open(output_op_path, "wt") as f: msg = op_template.render( - ops=ops, backward_ops=backward_ops, op_dict=op_dict + ops=ops, + backward_ops=backward_ops, + op_dict=op_dict, + composite_gen_flag=True, ) f.write(msg) - ks_template = env.get_template('ks.c.j2') with open(output_arg_map_path, 'wt') as f: msg = ks_template.render(ops=ops, backward_ops=backward_ops) diff --git a/paddle/fluid/operators/generator/generate_sparse_op.py b/paddle/fluid/operators/generator/generate_sparse_op.py index 1af4ee493b65d..1da91e3f60005 100644 --- a/paddle/fluid/operators/generator/generate_sparse_op.py +++ b/paddle/fluid/operators/generator/generate_sparse_op.py @@ -19,6 +19,7 @@ import yaml from filters import ( cartesian_prod_mapping, + to_composite_grad_opmaker_name, to_input_name, to_int_array_tensor_name, to_int_array_tensors_name, @@ -58,6 +59,7 @@ env.filters["to_input_name"] = to_input_name env.filters["to_opmaker_name_cstr"] = to_opmaker_name_cstr env.filters["cartesian_prod_mapping"] = cartesian_prod_mapping +env.filters["to_composite_grad_opmaker_name"] = to_composite_grad_opmaker_name env.tests["base_op"] = is_base_op env.tests["vec"] = is_vec env.tests["scalar"] = is_scalar @@ -134,7 +136,10 @@ def main(op_yaml_path, backward_yaml_path, output_op_path, output_arg_map_path): op_template = env.get_template('sparse_op.c.j2') with open(output_op_path, "wt") as f: msg = op_template.render( - ops=ops, backward_ops=backward_ops, op_dict=op_dict + ops=ops, + backward_ops=backward_ops, + op_dict=op_dict, + composite_gen_flag=False, ) f.write(msg) diff --git a/paddle/fluid/operators/generator/generate_static_op.py b/paddle/fluid/operators/generator/generate_static_op.py index b24e60dc4da1a..7701f76734a0c 100644 --- a/paddle/fluid/operators/generator/generate_static_op.py +++ b/paddle/fluid/operators/generator/generate_static_op.py @@ -19,6 +19,7 @@ import yaml from filters import ( cartesian_prod_mapping, + to_composite_grad_opmaker_name, to_input_name, to_int_array_tensor_name, to_int_array_tensors_name, @@ -58,6 +59,7 @@ env.filters["to_input_name"] = to_input_name env.filters["to_opmaker_name_cstr"] = to_opmaker_name_cstr env.filters["cartesian_prod_mapping"] = cartesian_prod_mapping +env.filters["to_composite_grad_opmaker_name"] = to_composite_grad_opmaker_name env.tests["base_op"] = is_base_op env.tests["vec"] = is_vec env.tests["scalar"] = is_scalar @@ -111,7 +113,10 @@ def main( op_template = env.get_template('op.c.j2') with open(output_op_path, "wt") as f: msg = op_template.render( - ops=ops, backward_ops=[], op_dict=forward_op_dict + ops=ops, + backward_ops=[], + op_dict=forward_op_dict, + composite_gen_flag=False, ) f.write(msg) diff --git a/paddle/fluid/operators/generator/parse_utils.py b/paddle/fluid/operators/generator/parse_utils.py index 408f026d9eb15..50eb318a2275f 100644 --- a/paddle/fluid/operators/generator/parse_utils.py +++ b/paddle/fluid/operators/generator/parse_utils.py @@ -289,6 +289,26 @@ def parse_forward(op_name: str, forward_config: str) -> Dict[str, Any]: return forward_cfg +def parse_composite( + op_name: str, + composite_config: str, +) -> Dict[str, Any]: + # composite_config: func(args1, args2,.....) + fname = r'(.*?)' + wspace = r'\s*' + fargs = r'(.*?)' + pattern = fr'{fname}{wspace}\({wspace}{fargs}{wspace}\)' + + m = re.search(pattern, composite_config) + func_name = m.group(1) + func_args = m.group(2) + + composite_dict = {} + composite_dict["func_name"] = func_name + composite_dict["func_args"] = func_args + return composite_dict + + def check_op_config(op_entry, op_name): base_key_set = ( 'op', @@ -332,9 +352,9 @@ def parse_op_entry(op_entry: Dict[str, Any], name_field="op"): op_name = op_entry[name_field] inputs, attrs = parse_input_and_attr(op_name, op_entry["args"]) outputs = parse_outputs(op_name, op_entry["output"]) - + if "composite" in op_entry: + composite_dict = parse_composite(op_name, op_entry["composite"]) check_op_config(op_entry, op_name) - # validate default value of DataType and DataLayout for attr in attrs: if "default_value" in attr: @@ -442,6 +462,10 @@ def parse_op_entry(op_entry: Dict[str, Any], name_field="op"): invoke = parse_invoke(op_name, op_entry["invoke"]) op["invoke"] = invoke + # has composite ? + if "composite" in op_entry: + op.update({"composite": composite_dict}) + # backward if "backward" in op_entry: backward = op_entry["backward"] diff --git a/paddle/fluid/operators/generator/templates/op.c.j2 b/paddle/fluid/operators/generator/templates/op.c.j2 index 92006c86d652f..23641dad90f1b 100644 --- a/paddle/fluid/operators/generator/templates/op.c.j2 +++ b/paddle/fluid/operators/generator/templates/op.c.j2 @@ -1,17 +1,20 @@ -{% from "operator_utils.c.j2" import op_maker, backward_op_maker, backward_op_reused_maker, operator, register_op_with_components, register_op_version %} +{% from "operator_utils.c.j2" import op_maker, backward_op_maker, backward_op_reused_maker, operator, register_op_with_components, register_op_version, composite_grad_op_maker %} // this file is generated by paddle/phi/api/yaml/generator/generate_op.py, do not edit. #include +#include "paddle/fluid/framework/convert_utils.h" #include "paddle/fluid/framework/infershape_utils.h" #include "paddle/fluid/framework/op_registry.h" #include "paddle/fluid/framework/op_version_registry.h" -#include "paddle/fluid/framework/convert_utils.h" +#include "paddle/fluid/prim/api/manual/backward/composite_backward_api.h" +#include "paddle/fluid/prim/utils/static/composite_grad_desc_maker.h" +#include "paddle/fluid/prim/utils/static/desc_tensor.h" #include "paddle/phi/core/infermeta_utils.h" -#include "paddle/phi/infermeta/nullary.h" -#include "paddle/phi/infermeta/unary.h" +#include "paddle/phi/infermeta/backward.h" #include "paddle/phi/infermeta/binary.h" -#include "paddle/phi/infermeta/ternary.h" #include "paddle/phi/infermeta/multiary.h" -#include "paddle/phi/infermeta/backward.h" +#include "paddle/phi/infermeta/nullary.h" +#include "paddle/phi/infermeta/ternary.h" +#include "paddle/phi/infermeta/unary.h" namespace paddle { namespace operators { @@ -36,6 +39,11 @@ using paddle::framework::GradVarName; {% else %} {{backward_op_reused_maker(op, op_dict[op["forward"]["name"]], op["invoke"])}} {% endif %} + {% if composite_gen_flag == True %} + {% if op is composite_op %} +{{composite_grad_op_maker(op_dict[op["name"]])}} + {% endif %} + {% endif %} {% endfor %} } // namespace operators } // namespace paddle @@ -43,7 +51,7 @@ using paddle::framework::GradVarName; namespace ops = paddle::operators; {% for op in ops + backward_ops %} {% if op is base_op %} -{{register_op_with_components(op)}} +{{register_op_with_components(op, op_dict)}} {{register_op_version(op)}} {% endif %} {% endfor %} diff --git a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 index 0112c98afccec..50c9310874d82 100644 --- a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 +++ b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 @@ -315,8 +315,9 @@ DECLARE_NO_NEED_BUFFER_VARS_INFERER({{op["op_name"] | to_pascal_case}}NoNeedBuff {% endif %} {% endmacro%} -{% macro register_op_with_components(op) %} +{% macro register_op_with_components(op, op_dict) %} {% set name = op["op_name"] %} +{% set phi_name = op["name"] %} REGISTER_OPERATOR({{name}}, ops::{{name | to_pascal_case}}Op, {% if not "forward" in op %}{# it is a forward op #} ops::{{name | to_pascal_case}}OpMaker, @@ -332,6 +333,9 @@ REGISTER_OPERATOR({{name}}, ops::{{name | to_pascal_case}}Op, {% if op is supports_inplace %}{# inplace#} ops::{{name | to_pascal_case}}InplaceInferer, {% endif %} +{% if "phi_backward" in op and op["phi_backward"] is not none and "composite" in op_dict[op["phi_backward"]] %} + ops::{{op["phi_backward"] | to_composite_grad_opmaker_name}}, +{% endif %} {% if op is supports_no_need_buffer %}{# no_need_buffer #} ops::{{name | to_pascal_case}}NoNeedBufferVarInferer, {% endif %} @@ -486,6 +490,155 @@ class {{name | to_pascal_case}}OpMaker : public framework::SingleGradOpMaker }; {% endmacro %} +{% macro composite_grad_op_maker(composite_op_dict) %} + {% set op_name = composite_op_dict["name"] %} +class {{op_name | to_composite_grad_opmaker_name}} : public prim::GradCompositeOpMakerBase { + public: + using prim::GradCompositeOpMakerBase::GradCompositeOpMakerBase; + void Apply() override { + //get inputs +{{construct_composite_input(composite_op_dict)}} + //get attr +{{construct_composite_attr(composite_op_dict)}} + //get output +{{construct_composite_output(composite_op_dict)}} + //get output ptr +{{construct_composite_output_ptr(composite_op_dict)}} + //get output orginal name +{{get_composite_output_orginal_name(composite_op_dict)}} + //call composite backward func +{{call_composite_backward_api(composite_op_dict)}} + //recover output name +{{recover_composite_output_name(composite_op_dict)}} + } +}; +{%- endmacro %} + +{% macro construct_composite_input(composite_op_dict) %} + {% set inputs = composite_op_dict["composite"]["phi_inputs"] %} + {% set input_dict = composite_op_dict["input_dict"] %} + {% set fluid_inputs = composite_op_dict["composite"]["fluid_inputs"] %} + {% set forward_fluid_inputs = composite_op_dict["forward"]["inputs"] | map(attribute="name") | list %} + {% set forward_fluid_outputs = composite_op_dict["forward"]["outputs"] | map(attribute="name") | list %} + {% set inputs_length = inputs | length %} + {% for i in range(inputs_length) %} + {% set input_typename = input_dict[inputs[i]]["typename"] %} + {% set input_optional_flag = input_dict[inputs[i]]["optional"] %} + {% if fluid_inputs[i] in forward_fluid_inputs %} + {% if input_typename == "Tensor" %} + {% if input_optional_flag == True %} + paddle::optional {{inputs[i]}} = this->GetOptionalSingleForwardInput("{{fluid_inputs[i]}}"); + {% elif input_optional_flag == False %} + paddle::experimental::Tensor {{inputs[i]}} = this->GetSingleForwardInput("{{fluid_inputs[i]}}"); + {% endif %} + {% elif input_typename == "Tensor[]" %} + {% if input_optional_flag == True %} + std::vector> {{inputs[i]}} = this->GetOptionalMultiForwardInput("{{fluid_inputs[i]}}"); + {% elif input_optional_flag == False %} + std::vector {{inputs[i]}} = this->GetMultiForwardInput("{{fluid_inputs[i]}}"); + {% endif %} + {% endif %} + {% elif fluid_inputs[i] in forward_fluid_outputs %} + {% if input_typename == "Tensor" %} + {% if input_optional_flag == True %} + paddle::optional {{inputs[i]}} = this->GetOptionalSingleForwardOutput("{{fluid_inputs[i]}}"); + {% elif input_optional_flag == False %} + paddle::experimental::Tensor {{inputs[i]}} = this->GetSingleForwardOutput("{{fluid_inputs[i]}}"); + {% endif %} + {% elif input_typename == "Tensor[]" %} + {% if input_optional_flag == True %} + std::vector> {{inputs[i]}} = this->GetOptionalMultiForwardOutput("{{fluid_inputs[i]}}"); + {% elif input_optional_flag == False %} + std::vector {{inputs[i]}} = this->GetMultiForwardOutput("{{fluid_inputs[i]}}"); + {% endif %} + {% endif %} + {% elif fluid_inputs[i][:-5] in forward_fluid_outputs %} + {% if input_typename == "Tensor" %} + {% if input_optional_flag == True %} + paddle::optional {{inputs[i]}} = this->GetOptionalSingleOutputGrad("{{fluid_inputs[i][:-5]}}"); + {% elif input_optional_flag == False %} + paddle::experimental::Tensor {{inputs[i]}} = this->GetSingleOutputGrad("{{fluid_inputs[i][:-5]}}"); + {% endif %} + {% elif input_typename == "Tensor[]" %} + {% if input_optional_flag == True %} + std::vector> {{inputs[i]}} = this->GetOptionalMultiOutputGrad("{{fluid_inputs[i][:-5]}}"); + {% elif input_optional_flag == False %} + std::vector {{inputs[i]}} = this->GetMultiOutputGrad("{{fluid_inputs[i][:-5]}}"); + {%- endif %} + {%- endif %} + {%- endif %} + {%- endfor %} +{%- endmacro %} + +{% macro construct_composite_attr(composite_op_dict) %} + {% set attrs = composite_op_dict["composite"]["phi_attrs"] %} + {% set fluid_attrs = composite_op_dict["composite"]["fluid_attrs"] %} + {% set fluid_attrs_dict = composite_op_dict["attr_dict"] %} + {% set attrs_length = attrs | length %} + {% for i in range(attrs_length) %} + {% set attrs_data_type = fluid_attrs_dict[fluid_attrs[i]]["typename"] | to_op_attr_type %} + {{attrs_data_type}} {{attrs[i]}} = this->Attr<{{attrs_data_type}}>("{{fluid_attrs[i]}}"); + {% endfor %} +{%- endmacro %} + +{% macro construct_composite_output(composite_op_dict) %} + {% set outputs = composite_op_dict["composite"]["phi_outputs"] %} + {% set fluid_outputs = composite_op_dict["composite"]["fluid_outputs"] %} + {% set outputs_dict = composite_op_dict["output_dict"] %} + {% set outputs_length = outputs | length %} + {% for i in range(outputs_length) %} + {% set output_typename = outputs_dict[outputs[i]]["typename"] %} + {% if output_typename == "Tensor" %} + paddle::experimental::Tensor {{outputs[i] + "_t"}} = this->GetSingleInputGrad("{{fluid_outputs[i][:-5]}}"); + {% elif output_typename == "Tensor[]" %} + std::vector {{outputs[i] + "_t"}} = this->GetMultiInputGrad("{{fluid_outputs[i][:-5]}}"); + {%- endif %} + {%- endfor %} +{%- endmacro %} + +{% macro construct_composite_output_ptr(composite_op_dict) %} + {% set outputs = composite_op_dict["composite"]["phi_outputs"] %} + {% set outputs_dict = composite_op_dict["output_dict"] %} + {% set outputs_length = outputs | length %} + {% for i in range(outputs_length) %} + {% set output_typename = outputs_dict[outputs[i]]["typename"] %} + {% if output_typename == "Tensor" %} + paddle::experimental::Tensor* {{outputs[i]}} = this->GetOutputPtr(&{{outputs[i]+ "_t"}}); + {% elif output_typename == "Tensor[]" %} + std::vector {{outputs[i]}}({{outputs[i] + "_t"}}.size()); + for(size_t i = 0; i < {{outputs[i]}}.size(); ++i){ + {{outputs[i]}}[i] = &{{outputs[i] + "_t"}}[i]; + } + {{outputs[i]}} = this->GetOutputPtr({{outputs[i]}}); + {%- endif %} + {%- endfor %} +{%- endmacro %} + +{% macro get_composite_output_orginal_name(composite_op_dict) %} + {% set outputs = composite_op_dict["composite"]["phi_outputs"] %} + {% set outputs_dict = composite_op_dict["output_dict"] %} + {% set outputs_length = outputs | length %} + {% for i in range(outputs_length) %} + {% set output_typename = outputs_dict[outputs[i]]["typename"] %} + {% if output_typename == "Tensor" %} + std::string {{outputs[i] + "_name"}} = this->GetOutputName({{outputs[i] + "_t"}}); + {% elif output_typename == "Tensor[]" %} + std::vector {{outputs[i] + "_name"}} = this->GetOutputName({{outputs[i] + "_t"}}); + {%- endif %} + {%- endfor %} +{%- endmacro %} + +{% macro call_composite_backward_api(composite_op_dict) %} + prim::{{composite_op_dict["composite"]["func_name"]}}({{composite_op_dict["composite"]["func_args"]}}); +{%- endmacro %} + +{% macro recover_composite_output_name(composite_op_dict) %} + {% set outputs = composite_op_dict["composite"]["phi_outputs"] %} + {% set outputs_length = outputs | length %} + {% for i in range(outputs_length) %} + this->RecoverOutputName({{outputs[i] + "_t"}}, {{outputs[i] + "_name"}}); + {% endfor %} +{%- endmacro %} {% macro extract_input_from_forward(name, input_names, output_names, diff --git a/paddle/fluid/operators/generator/tests.py b/paddle/fluid/operators/generator/tests.py index 0c6c5cf0f3f8a..29c4bea8066f4 100644 --- a/paddle/fluid/operators/generator/tests.py +++ b/paddle/fluid/operators/generator/tests.py @@ -46,6 +46,10 @@ def is_base_op(op): return "kernel" in op and "infer_meta" in op +def is_composite_op(op): + return "composite" in op + + def supports_selected_rows_kernel(op): return is_base_op(op) and len(op["kernel"]["func"]) == 2 diff --git a/paddle/fluid/prim/tests/test_static_prim.cc b/paddle/fluid/prim/tests/test_static_prim.cc index 5c167899796ca..87475559617fb 100644 --- a/paddle/fluid/prim/tests/test_static_prim.cc +++ b/paddle/fluid/prim/tests/test_static_prim.cc @@ -32,6 +32,7 @@ PD_DECLARE_KERNEL(tanh_grad, CPU, ALL_LAYOUT); PD_DECLARE_KERNEL(pow, CPU, ALL_LAYOUT); PD_DECLARE_KERNEL(scale, CPU, ALL_LAYOUT); PD_DECLARE_KERNEL(multiply, CPU, ALL_LAYOUT); +PD_DECLARE_KERNEL(concat, CPU, ALL_LAYOUT); #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) PD_DECLARE_KERNEL(full, GPU, ALL_LAYOUT); PD_DECLARE_KERNEL(tanh, GPU, ALL_LAYOUT); @@ -39,6 +40,7 @@ PD_DECLARE_KERNEL(tanh_grad, GPU, ALL_LAYOUT); PD_DECLARE_KERNEL(pow, GPU, ALL_LAYOUT); PD_DECLARE_KERNEL(scale, GPU, ALL_LAYOUT); PD_DECLARE_KERNEL(multiply, KPS, ALL_LAYOUT); +PD_DECLARE_KERNEL(concat, GPU, ALL_LAYOUT); #endif namespace paddle { namespace prim { @@ -93,11 +95,52 @@ struct TestBaseProgram { return program_.MutableBlock(id); } + void concat(std::vector inputs, + int axis, + framework::VarDesc* out) { + framework::OpDesc* op = program_.MutableBlock(0)->AppendOp(); + op->SetType("concat"); + std::vector input_names(inputs.size()); + for (size_t i = 0; i < inputs.size(); ++i) { + input_names[i] = inputs[i]->Name(); + } + op->SetInput("X", input_names); + op->SetOutput("Out", {out->Name()}); + op->SetAttr("axis", axis); + op->SetAttr(framework::OpProtoAndCheckerMaker::OpRoleAttrName(), + static_cast(framework::OpRole::kForward)); + } + + void split(framework::VarDesc* input, + int num, + int axis, + std::vector outputs) { + framework::OpDesc* op = program_.MutableBlock(0)->AppendOp(); + op->SetType("split"); + const std::string input_name = input->Name(); + std::vector output_names(outputs.size()); + for (size_t i = 0; i < outputs.size(); ++i) { + output_names[i] = outputs[i]->Name(); + } + op->SetInput("X", {input_name}); + op->SetOutput("Out", output_names); + op->SetAttr("num", num); + op->SetAttr("axis", axis); + op->SetAttr(framework::OpProtoAndCheckerMaker::OpRoleAttrName(), + static_cast(framework::OpRole::kForward)); + } + private: framework::ProgramDesc program_; int idx_{0}; }; +class TestGradCompositeGradMaker : public GradCompositeOpMakerBase { + public: + using prim::GradCompositeOpMakerBase::GradCompositeOpMakerBase; + void Apply() override {} +}; + TEST(StaticPrim, TanhBackwardComposite) { TestBaseProgram base_program = TestBaseProgram(); auto* target_block = base_program.GetBlock(0); @@ -179,12 +222,131 @@ TEST(StaticPrim, TanhBackwardComposite) { static_cast(1)); } +TEST(StaticCompositeGradMaker, TestMutiInputMethod) { + TestBaseProgram base_program = TestBaseProgram(); + auto* target_block = base_program.GetBlock(0); + std::vector shape = {2, 2}; + std::vector shape_out = {4, 2}; + StaticCompositeContext::Instance().SetBlock(target_block); + Tensor x0 = prim::empty( + shape, phi::DataType::FLOAT32, paddle::Place()); + Tensor x1 = prim::empty( + shape, phi::DataType::FLOAT32, paddle::Place()); + Tensor out = prim::empty( + shape_out, phi::DataType::FLOAT32, paddle::Place()); + framework::VarDesc* x0_desc = + static_cast(x0.impl().get())->get_ptr(); + target_block->RenameVar(x0_desc->Name(), "x0"); + framework::VarDesc* x1_desc = + static_cast(x1.impl().get())->get_ptr(); + target_block->RenameVar(x1_desc->Name(), "x1"); + framework::VarDesc* out_desc = + static_cast(out.impl().get())->get_ptr(); + target_block->RenameVar(out_desc->Name(), "out"); + std::vector inputs = {target_block->FindVar("x0"), + target_block->FindVar("x1")}; + framework::VarDesc* output = target_block->FindVar("out"); + base_program.concat(inputs, 0, output); + auto* forward_opdesc = target_block->AllOps()[0]; + std::unordered_map grad_to_var; + std::vector grad_sub_block; + auto test = TestGradCompositeGradMaker(*forward_opdesc, + std::unordered_set(), + &grad_to_var, + target_block, + grad_sub_block); + test(); + std::vector muti_fw_input = + test.GetMultiForwardInput("X"); + std::vector> + opt_muti_fw_input = test.GetOptionalMultiForwardInput("X"); + paddle::experimental::Tensor fw_out = test.GetSingleForwardOutput("Out"); + paddle::experimental::Tensor* fw_out_ptr = test.GetOutputPtr(&fw_out); + std::string fw_out_name = test.GetOutputName(fw_out); + + ASSERT_EQ(muti_fw_input.size(), static_cast(2)); + ASSERT_EQ( + static_cast(muti_fw_input[0].impl().get())->Name(), + "x0"); + ASSERT_EQ( + static_cast(muti_fw_input[1].impl().get())->Name(), + "x1"); + ASSERT_EQ(opt_muti_fw_input.size(), static_cast(2)); + ASSERT_EQ(static_cast( + opt_muti_fw_input[0].get_ptr()->impl().get()) + ->Name(), + "x0"); + ASSERT_EQ(static_cast( + opt_muti_fw_input[1].get_ptr()->impl().get()) + ->Name(), + "x1"); + ASSERT_EQ(&fw_out, fw_out_ptr); + ASSERT_EQ(fw_out_name, "out"); +} + +TEST(StaticCompositeGradMaker, TestMutiOutputMethod) { + TestBaseProgram base_program = TestBaseProgram(); + auto* target_block = base_program.GetBlock(0); + std::vector shape = {4, 2}; + std::vector shape_out = {2, 2}; + StaticCompositeContext::Instance().SetBlock(target_block); + Tensor x = prim::empty( + shape, phi::DataType::FLOAT32, paddle::Place()); + Tensor out1 = prim::empty( + shape_out, phi::DataType::FLOAT32, paddle::Place()); + Tensor out2 = prim::empty( + shape_out, phi::DataType::FLOAT32, paddle::Place()); + framework::VarDesc* x_desc = + static_cast(x.impl().get())->get_ptr(); + target_block->RenameVar(x_desc->Name(), "x"); + framework::VarDesc* out1_desc = + static_cast(out1.impl().get())->get_ptr(); + target_block->RenameVar(out1_desc->Name(), "out1"); + framework::VarDesc* out2_desc = + static_cast(out2.impl().get())->get_ptr(); + target_block->RenameVar(out2_desc->Name(), "out2"); + framework::VarDesc* input = target_block->FindVar("x"); + std::vector outputs = {target_block->FindVar("out1"), + target_block->FindVar("out2")}; + base_program.split(input, 2, 0, outputs); + auto* forward_opdesc = target_block->AllOps()[0]; + std::unordered_map grad_to_var; + std::vector grad_sub_block; + auto test = TestGradCompositeGradMaker(*forward_opdesc, + std::unordered_set(), + &grad_to_var, + target_block, + grad_sub_block); + test(); + paddle::experimental::Tensor fw_input = test.GetSingleForwardInput("X"); + paddle::optional opt_fw_input = + test.GetOptionalSingleForwardInput("X"); + std::vector fw_out = + test.GetMultiForwardOutput("Out"); + std::vector fw_out_ptr(fw_out.size()); + for (size_t i = 0; i < fw_out.size(); ++i) { + fw_out_ptr[i] = &fw_out[i]; + } + fw_out_ptr = test.GetOutputPtr(fw_out_ptr); + std::vector fw_out_name = test.GetOutputName(fw_out); + ASSERT_EQ(static_cast(fw_input.impl().get())->Name(), "x"); + ASSERT_EQ(static_cast(opt_fw_input.get_ptr()->impl().get()) + ->Name(), + "x"); + ASSERT_EQ(fw_out.size(), static_cast(2)); + ASSERT_EQ(fw_out_ptr[0], &fw_out[0]); + ASSERT_EQ(fw_out_ptr[1], &fw_out[1]); + ASSERT_EQ(fw_out_name[0], "out1"); + ASSERT_EQ(fw_out_name[1], "out2"); +} + TEST(StaticPrim, TestFlags) { PrimCommonUtils::SetPrimEnabled(true); ASSERT_TRUE(PrimCommonUtils::IsPrimEnabled()); PrimCommonUtils::SetPrimEnabled(false); ASSERT_FALSE(PrimCommonUtils::IsPrimEnabled()); } + } // namespace prim } // namespace paddle USE_OP_ITSELF(tanh); diff --git a/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h b/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h index bf8e4874c172f..e053d1465e70d 100644 --- a/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h +++ b/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h @@ -26,6 +26,7 @@ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/program_desc.h" #include "paddle/fluid/framework/type_defs.h" +#include "paddle/fluid/prim/utils/static/desc_tensor.h" #include "paddle/fluid/prim/utils/static/static_global_utils.h" #include "paddle/phi/core/enforce.h" namespace paddle { @@ -75,6 +76,224 @@ class GradCompositeOpMakerBase { virtual void Apply() = 0; + paddle::experimental::Tensor GetSingleForwardOutput(const std::string& name) { + framework::VarDesc* out_desc = this->SingleForwardOutput(name); + paddle::experimental::Tensor out = + paddle::experimental::Tensor(std::make_shared(out_desc)); + return out; + } + + paddle::experimental::Tensor GetSingleForwardInput(const std::string& name) { + paddle::experimental::Tensor input = paddle::experimental::Tensor( + std::make_shared(this->SingleForwardInput(name))); + return input; + } + + paddle::experimental::Tensor GetSingleOutputGrad(const std::string& name) { + paddle::experimental::Tensor output_grad = paddle::experimental::Tensor( + std::make_shared(this->SingleOutputGrad(name))); + return output_grad; + } + + paddle::experimental::Tensor GetSingleInputGrad(const std::string& name) { + framework::VarDesc* input_grad_desc = this->SingleInputGrad(name); + if (!input_grad_desc) return paddle::experimental::Tensor(); + paddle::experimental::Tensor input_grad = paddle::experimental::Tensor( + std::make_shared(input_grad_desc)); + return input_grad; + } + + paddle::optional GetOptionalSingleForwardOutput( + const std::string& name) { + paddle::optional output_opt; + framework::VarDesc* output_desc = this->SingleForwardOutput(name); + if (!output_desc) return output_opt; + paddle::experimental::Tensor output = + paddle::experimental::Tensor(std::make_shared(output_desc)); + output_opt = paddle::make_optional(output); + return output_opt; + } + + paddle::optional GetOptionalSingleForwardInput( + const std::string& name) { + paddle::optional input_opt; + framework::VarDesc* input_desc = this->SingleForwardInput(name); + if (!input_desc) return input_opt; + paddle::experimental::Tensor input = + paddle::experimental::Tensor(std::make_shared(input_desc)); + input_opt = paddle::make_optional(input); + return input_opt; + } + + paddle::optional GetOptionalSingleOutputGrad( + const std::string& name) { + paddle::optional output_grad_opt; + framework::VarDesc* output_grad_desc = this->SingleOutputGrad(name); + if (!output_grad_desc) return output_grad_opt; + paddle::experimental::Tensor output_grad = paddle::experimental::Tensor( + std::make_shared(output_grad_desc)); + output_grad_opt = + paddle::make_optional(output_grad); + return output_grad_opt; + } + + std::vector GetMultiForwardOutput( + const std::string& name) { + std::vector outputs; + std::vector outputs_descs = + this->MultiForwardOutput(name); + outputs.reserve(outputs_descs.size()); + for (const auto& output_desc : outputs_descs) { + outputs.emplace_back(paddle::experimental::Tensor( + std::make_shared(output_desc))); + } + return outputs; + } + + std::vector GetMultiForwardInput( + const std::string& name) { + std::vector inputs; + std::vector inputs_descs = + this->MultiForwardInput(name); + inputs.reserve(inputs_descs.size()); + for (const auto& input_desc : inputs_descs) { + inputs.emplace_back(paddle::experimental::Tensor( + std::make_shared(input_desc))); + } + return inputs; + } + + std::vector GetMultiOutputGrad( + const std::string& name) { + std::vector outputs_grads; + std::vector outputs_grads_descs = + this->MultiOutputGrad(name); + outputs_grads.reserve(outputs_grads_descs.size()); + for (const auto& output_grad_desc : outputs_grads_descs) { + outputs_grads.emplace_back(paddle::experimental::Tensor( + std::make_shared(output_grad_desc))); + } + return outputs_grads; + } + + std::vector GetMultiInputGrad( + const std::string& name) { + std::vector inputs_grads; + std::vector inputs_grads_descs = + this->MultiInputGrad(name); + inputs_grads.reserve(inputs_grads_descs.size()); + for (const auto& input_grad_desc : inputs_grads_descs) { + if (input_grad_desc) { + inputs_grads.emplace_back(paddle::experimental::Tensor( + std::make_shared(input_grad_desc))); + } else { + inputs_grads.emplace_back(paddle::experimental::Tensor()); + } + } + return inputs_grads; + } + + std::vector> + GetOptionalMultiForwardOutput(const std::string& name) { + std::vector> outputs_opt; + std::vector outputs_descs = + this->MultiForwardOutput(name); + outputs_opt.reserve(outputs_descs.size()); + for (const auto& output_desc : outputs_descs) { + if (output_desc) { + outputs_opt.emplace_back( + paddle::make_optional( + paddle::experimental::Tensor( + std::make_shared(output_desc)))); + } else { + outputs_opt.emplace_back( + paddle::make_optional( + paddle::experimental::Tensor())); + } + } + return outputs_opt; + } + + std::vector> + GetOptionalMultiForwardInput(const std::string& name) { + std::vector> inputs_opt; + std::vector inputs_descs = + this->MultiForwardInput(name); + inputs_opt.reserve(inputs_descs.size()); + for (const auto& input_desc : inputs_descs) { + if (input_desc) { + inputs_opt.emplace_back( + paddle::make_optional( + paddle::experimental::Tensor( + std::make_shared(input_desc)))); + } else { + inputs_opt.emplace_back( + paddle::make_optional( + paddle::experimental::Tensor())); + } + } + return inputs_opt; + } + + std::vector> + GetOptionalMultiOutputGrad(const std::string& name) { + std::vector> outputs_grads; + std::vector outputs_grads_descs = + this->MultiOutputGrad(name); + outputs_grads.reserve(outputs_grads_descs.size()); + for (const auto& output_grad_desc : outputs_grads_descs) { + if (output_grad_desc) { + outputs_grads.emplace_back( + paddle::make_optional( + paddle::experimental::Tensor( + std::make_shared(output_grad_desc)))); + } else { + outputs_grads.emplace_back( + paddle::make_optional( + paddle::experimental::Tensor())); + } + } + return outputs_grads; + } + + paddle::experimental::Tensor* GetOutputPtr( + paddle::experimental::Tensor* input) { + if (input->defined()) return input; + return nullptr; + } + + std::vector GetOutputPtr( + const std::vector& inputs) { + std::vector output_ptrs; + output_ptrs.reserve(inputs.size()); + for (const auto& input : inputs) { + if (input->defined()) + output_ptrs.emplace_back(input); + else + output_ptrs.emplace_back(nullptr); + } + return output_ptrs; + } + + std::string GetOutputName(const paddle::experimental::Tensor& output) { + if (!output.defined()) return framework::kEmptyVarName; + return static_cast(output.impl().get())->Name(); + } + + std::vector GetOutputName( + const std::vector& outputs) { + std::vector out_names; + out_names.reserve(outputs.size()); + for (const auto& output : outputs) { + if (!output.defined()) + out_names.emplace_back(framework::kEmptyVarName); + else + out_names.emplace_back( + static_cast(output.impl().get())->Name()); + } + return out_names; + } + protected: void CopyVarFromOrig(const std::string& name) const { VLOG(6) << "Copy Var: " << name << "from block: " << original_block_ @@ -255,6 +474,32 @@ class GradCompositeOpMakerBase { return result; } + void RecoverOutputName(const paddle::experimental::Tensor& output, + const std::string& origin_name) { + if (origin_name == framework::kEmptyVarName) return; + prim::StaticCompositeContext::Instance().GetBlock()->RenameVar( + static_cast(output.impl().get())->Name(), + origin_name); + } + + void RecoverOutputName( + const std::vector& outputs, + const std::vector& origin_names) { + PADDLE_ENFORCE_EQ(outputs.size(), + origin_names.size(), + platform::errors::InvalidArgument( + "The size of outputs must be equal to the size " + "of the origin_names.", + outputs.size(), + origin_names.size())); + for (size_t i = 0; i < outputs.size(); ++i) { + if (origin_names[i] == framework::kEmptyVarName) continue; + prim::StaticCompositeContext::Instance().GetBlock()->RenameVar( + static_cast(outputs[i].impl().get())->Name(), + origin_names[i]); + } + } + std::string SingleForwardInputVarName(const std::string& name) const { return fwd_op_.Input(name).at(0); }