2424namespace paddle {
2525namespace operators {
2626
27- class ViewAsComplexOp : public framework ::OperatorWithKernel {
27+ class AsComplexOp : public framework ::OperatorWithKernel {
2828 public:
2929 using framework::OperatorWithKernel::OperatorWithKernel;
3030
3131 void InferShape (framework::InferShapeContext *ctx) const override {
32- OP_INOUT_CHECK (ctx->HasInput (" X" ), " Input" , " X" , " view_as_complex " );
33- OP_INOUT_CHECK (ctx->HasOutput (" Out" ), " Output" , " Out" , " view_as_complex " );
32+ OP_INOUT_CHECK (ctx->HasInput (" X" ), " Input" , " X" , " as_complex " );
33+ OP_INOUT_CHECK (ctx->HasOutput (" Out" ), " Output" , " Out" , " as_complex " );
3434
3535 auto in_dims = ctx->GetInputDim (" X" );
3636 const int input_rank = in_dims.size ();
@@ -57,15 +57,15 @@ class ViewAsComplexOp : public framework::OperatorWithKernel {
5757 }
5858};
5959
60- class ViewAsComplexOpMaker : public framework ::OpProtoAndCheckerMaker {
60+ class AsComplexOpMaker : public framework ::OpProtoAndCheckerMaker {
6161 public:
6262 void Make () override {
6363 AddInput (" X" , " (Tensor), The input tensor of view_as_complex op." );
6464 AddOutput (" Out" , " (Tensor), The output tensor of view_as_complex op." );
6565 AddComment (R"DOC(
66- View_as_complex Operator.
66+ As_complex Operator.
6767
68- This operator is used to return a complex tensor view represented
68+ This operator is used to return a complex tensor represented
6969by an old-fashioned real tensor. The size of the last dimension of
7070the input tensor should be 2, which corresponds to 'real' and
7171'complex', respectively.
@@ -75,25 +75,25 @@ the input tensor should be 2, which corresponds to 'real' and
7575};
7676
7777template <typename T>
78- class ViewAsComplexGradMaker : public framework ::SingleGradOpMaker<T> {
78+ class AsComplexGradMaker : public framework ::SingleGradOpMaker<T> {
7979 public:
8080 using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
8181
8282 void Apply (GradOpPtr<T> retv) const override {
83- retv->SetType (" view_as_real " );
83+ retv->SetType (" as_real " );
8484 retv->SetInput (" X" , this ->OutputGrad (" Out" ));
8585 retv->SetAttrMap (this ->Attrs ());
8686 retv->SetOutput (" Out" , this ->InputGrad (" X" ));
8787 }
8888};
8989
90- class ViewAsRealOp : public framework ::OperatorWithKernel {
90+ class AsRealOp : public framework ::OperatorWithKernel {
9191 public:
9292 using framework::OperatorWithKernel::OperatorWithKernel;
9393
9494 void InferShape (framework::InferShapeContext *ctx) const override {
95- OP_INOUT_CHECK (ctx->HasInput (" X" ), " Input" , " X" , " view_as_real " );
96- OP_INOUT_CHECK (ctx->HasOutput (" Out" ), " Output" , " Out" , " view_as_real " );
95+ OP_INOUT_CHECK (ctx->HasInput (" X" ), " Input" , " X" , " as_real " );
96+ OP_INOUT_CHECK (ctx->HasOutput (" Out" ), " Output" , " Out" , " as_real " );
9797
9898 auto out_dims_v = framework::vectorize (ctx->GetInputDim (" X" ));
9999 out_dims_v.push_back (2 );
@@ -112,15 +112,15 @@ class ViewAsRealOp : public framework::OperatorWithKernel {
112112 }
113113};
114114
115- class ViewAsRealOpMaker : public framework ::OpProtoAndCheckerMaker {
115+ class AsRealOpMaker : public framework ::OpProtoAndCheckerMaker {
116116 public:
117117 void Make () override {
118- AddInput (" X" , " (Tensor), The input tensor of view_as_real op." );
119- AddOutput (" Out" , " (Tensor), The output tensor of view_as_real op." );
118+ AddInput (" X" , " (Tensor), The input tensor of as_real op." );
119+ AddOutput (" Out" , " (Tensor), The output tensor of as_real op." );
120120 AddComment (R"DOC(
121- View_as_real Operator.
121+ AsReal Operator.
122122
123- This operator is used to return an old-fashioned real tensor view of a
123+ This operator is used to return an old-fashioned real tensor from a
124124complex tensor. The size of the last dimension of the output tensor is 2,
125125which corresponds to 'real' and 'complex', respectively.
126126
@@ -129,12 +129,12 @@ which corresponds to 'real' and 'complex', respectively.
129129};
130130
131131template <typename T>
132- class ViewAsRealGradMaker : public framework ::SingleGradOpMaker<T> {
132+ class AsRealGradMaker : public framework ::SingleGradOpMaker<T> {
133133 public:
134134 using framework::SingleGradOpMaker<T>::SingleGradOpMaker;
135135
136136 void Apply (GradOpPtr<T> retv) const override {
137- retv->SetType (" view_as_complex " );
137+ retv->SetType (" as_complex " );
138138 retv->SetInput (" X" , this ->OutputGrad (" Out" ));
139139 retv->SetAttrMap (this ->Attrs ());
140140 retv->SetOutput (" Out" , this ->InputGrad (" X" ));
@@ -146,23 +146,18 @@ class ViewAsRealGradMaker : public framework::SingleGradOpMaker<T> {
146146
147147namespace ops = paddle::operators;
148148
149- REGISTER_OPERATOR (view_as_complex, ops::ViewAsComplexOp,
150- ops::ViewAsComplexOpMaker,
151- ops::ViewAsComplexGradMaker<paddle::framework::OpDesc>,
152- ops::ViewAsComplexGradMaker<paddle::imperative::OpBase>,
153- ops::ViewAsComplexOpInplaceInferer);
149+ REGISTER_OPERATOR (as_complex, ops::AsComplexOp, ops::AsComplexOpMaker,
150+ ops::AsComplexGradMaker<paddle::framework::OpDesc>,
151+ ops::AsComplexGradMaker<paddle::imperative::OpBase>);
154152
155- REGISTER_OPERATOR (view_as_real, ops::ViewAsRealOp, ops::ViewAsRealOpMaker,
156- ops::ViewAsRealGradMaker<paddle::framework::OpDesc>,
157- ops::ViewAsRealGradMaker<paddle::imperative::OpBase>,
158- ops::ViewAsRealOpInplaceInferer);
153+ REGISTER_OPERATOR (as_real, ops::AsRealOp, ops::AsRealOpMaker,
154+ ops::AsRealGradMaker<paddle::framework::OpDesc>,
155+ ops::AsRealGradMaker<paddle::imperative::OpBase>);
159156
160157REGISTER_OP_CPU_KERNEL (
161- view_as_complex,
162- ops::ViewAsComplexKernel<paddle::platform::CPUDeviceContext, float >,
163- ops::ViewAsComplexKernel<paddle::platform::CPUDeviceContext, double >);
158+ as_complex, ops::AsComplexKernel<paddle::platform::CPUDeviceContext, float >,
159+ ops::AsComplexKernel<paddle::platform::CPUDeviceContext, double >);
164160
165161REGISTER_OP_CPU_KERNEL (
166- view_as_real,
167- ops::ViewAsRealKernel<paddle::platform::CPUDeviceContext, float >,
168- ops::ViewAsRealKernel<paddle::platform::CPUDeviceContext, double >);
162+ as_real, ops::AsRealKernel<paddle::platform::CPUDeviceContext, float >,
163+ ops::AsRealKernel<paddle::platform::CPUDeviceContext, double >);
0 commit comments