diff --git a/paddle/fluid/operators/gru_op.cc b/paddle/fluid/operators/gru_op.cc index 2d58438dbf35ea0fcca7a3930f13f716752a257b..921076a4a1406ef9026bb63f0159ef92de2e3144 100644 --- a/paddle/fluid/operators/gru_op.cc +++ b/paddle/fluid/operators/gru_op.cc @@ -313,11 +313,10 @@ class GRUGradOp : public framework::OperatorWithKernel { } }; -template +template class GRUCPUKernel : public framework::OpKernel { public: void BatchCompute(const framework::ExecutionContext& context) const { - using DeviceContext = phi::CPUContext; using LodTensorPtr = phi::DenseTensor*; bool is_test = context.Attr("is_test"); @@ -585,9 +584,8 @@ REGISTER_OPERATOR(gru, REGISTER_OPERATOR(gru_grad, ops::GRUGradOp, ops::GRUGradOpNoNeedBufferVarInferer); -REGISTER_OP_CPU_KERNEL(gru, - ops::GRUCPUKernel, - ops::GRUCPUKernel); -REGISTER_OP_CPU_KERNEL(gru_grad, - ops::GRUGradKernel, - ops::GRUGradKernel); + +PD_REGISTER_STRUCT_KERNEL( + gru, CPU, ALL_LAYOUT, ops::GRUCPUKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + gru_grad, CPU, ALL_LAYOUT, ops::GRUGradKernel, float, double) {} diff --git a/paddle/fluid/operators/gru_op.cu.cc b/paddle/fluid/operators/gru_op.cu.cc index 0d3686bb495ef903a0926c1591faeac8cc394335..f89400fca5373ae0c142d53e8fdf98d26728818d 100644 --- a/paddle/fluid/operators/gru_op.cu.cc +++ b/paddle/fluid/operators/gru_op.cu.cc @@ -17,7 +17,7 @@ limitations under the License. */ namespace paddle { namespace operators { -template +template class GRUKernel : public framework::OpKernel { public: void BatchCompute(const framework::ExecutionContext& context) const { @@ -133,9 +133,8 @@ class GRUKernel : public framework::OpKernel { } // namespace paddle namespace ops = paddle::operators; -REGISTER_OP_CUDA_KERNEL(gru, - ops::GRUKernel, - ops::GRUKernel); -REGISTER_OP_CUDA_KERNEL(gru_grad, - ops::GRUGradKernel, - ops::GRUGradKernel); + +PD_REGISTER_STRUCT_KERNEL(gru, GPU, ALL_LAYOUT, ops::GRUKernel, float, double) { +} +PD_REGISTER_STRUCT_KERNEL( + gru_grad, GPU, ALL_LAYOUT, ops::GRUGradKernel, float, double) {} diff --git a/paddle/fluid/operators/gru_op.h b/paddle/fluid/operators/gru_op.h index 760a33a161cabbcd7c9b1ce41915336f2a5087b4..f2fc7663d972a676ab66a67d5012c99d2c231b59 100644 --- a/paddle/fluid/operators/gru_op.h +++ b/paddle/fluid/operators/gru_op.h @@ -36,7 +36,7 @@ inline void ReorderInitState(const DeviceContext& ctx, row_shuffle(ctx, src, index_lod, dst, indexed_src); } -template +template class GRUGradKernel : public framework::OpKernel { public: void BatchCompute(const framework::ExecutionContext& context) const { diff --git a/paddle/fluid/operators/gru_unit_op.cc b/paddle/fluid/operators/gru_unit_op.cc index 7bd104472fe558682d73eecdf19028362671258a..3c8b2947e5fce846b3815adb1a3faead0b034631 100644 --- a/paddle/fluid/operators/gru_unit_op.cc +++ b/paddle/fluid/operators/gru_unit_op.cc @@ -323,9 +323,7 @@ REGISTER_OPERATOR(gru_unit_grad, ops::GRUUnitGradOp, ops::GRUUnitGradOpNoNeedBufferVarInferer); -REGISTER_OP_CPU_KERNEL(gru_unit, - ops::GRUUnitKernel, - ops::GRUUnitKernel); -REGISTER_OP_CPU_KERNEL(gru_unit_grad, - ops::GRUUnitGradKernel, - ops::GRUUnitGradKernel); +PD_REGISTER_STRUCT_KERNEL( + gru_unit, CPU, ALL_LAYOUT, ops::GRUUnitKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + gru_unit_grad, CPU, ALL_LAYOUT, ops::GRUUnitGradKernel, float, double) {} diff --git a/paddle/fluid/operators/gru_unit_op.cu b/paddle/fluid/operators/gru_unit_op.cu index adaaf1d09cd76460d2694bf09055d5acec4146de..192594a09e86f5be996b8eb2560bd33433d07381 100644 --- a/paddle/fluid/operators/gru_unit_op.cu +++ b/paddle/fluid/operators/gru_unit_op.cu @@ -14,9 +14,8 @@ limitations under the License. */ #include "paddle/fluid/operators/gru_unit_op.h" namespace ops = paddle::operators; -REGISTER_OP_CUDA_KERNEL(gru_unit, - ops::GRUUnitKernel, - ops::GRUUnitKernel); -REGISTER_OP_CUDA_KERNEL(gru_unit_grad, - ops::GRUUnitGradKernel, - ops::GRUUnitGradKernel); + +PD_REGISTER_STRUCT_KERNEL( + gru_unit, GPU, ALL_LAYOUT, ops::GRUUnitKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + gru_unit_grad, GPU, ALL_LAYOUT, ops::GRUUnitGradKernel, float, double) {} diff --git a/paddle/fluid/operators/gru_unit_op.h b/paddle/fluid/operators/gru_unit_op.h index c22a82c5ae8fd62bb080780f9810cd9ef03a5531..9309ca0417f62d6c57b9c49aaafec4a05595f236 100644 --- a/paddle/fluid/operators/gru_unit_op.h +++ b/paddle/fluid/operators/gru_unit_op.h @@ -25,7 +25,7 @@ namespace operators { enum GRUActivationType { identity = 0, sigmoid = 1, tanh = 2, relu = 3 }; -template +template class GRUUnitKernel : public framework::OpKernel { public: template @@ -153,7 +153,7 @@ class GRUUnitKernel : public framework::OpKernel { } }; -template +template class GRUUnitGradKernel : public framework::OpKernel { public: template diff --git a/paddle/fluid/operators/lrn_op.cc b/paddle/fluid/operators/lrn_op.cc index 96d5a115991b01f0aab214423ceeb0985b40e01f..d16b2abf4716a5f29ec1ef4a955b48f79d971688 100644 --- a/paddle/fluid/operators/lrn_op.cc +++ b/paddle/fluid/operators/lrn_op.cc @@ -400,5 +400,7 @@ REGISTER_OPERATOR(lrn, ops::LRNGradOpMaker); REGISTER_OPERATOR(lrn_grad, ops::LRNOpGrad); -REGISTER_OP_CPU_KERNEL(lrn, ops::LRNKernel); -REGISTER_OP_CPU_KERNEL(lrn_grad, ops::LRNGradKernel); + +PD_REGISTER_STRUCT_KERNEL(lrn, CPU, ALL_LAYOUT, ops::LRNKernel, float) {} +PD_REGISTER_STRUCT_KERNEL( + lrn_grad, CPU, ALL_LAYOUT, ops::LRNGradKernel, float) {} diff --git a/paddle/fluid/operators/lrn_op.cu b/paddle/fluid/operators/lrn_op.cu index 22b4f0c4618374e3f8384faaef3781b5882fbdb3..20f56cb8f9b947aca511c24c448c96b11cb1e800 100644 --- a/paddle/fluid/operators/lrn_op.cu +++ b/paddle/fluid/operators/lrn_op.cu @@ -274,5 +274,6 @@ template struct LRNGradFunctor; } // namespace paddle namespace ops = paddle::operators; -REGISTER_OP_CUDA_KERNEL(lrn, ops::LRNKernel); -REGISTER_OP_CUDA_KERNEL(lrn_grad, ops::LRNGradKernel); +PD_REGISTER_STRUCT_KERNEL(lrn, GPU, ALL_LAYOUT, ops::LRNKernel, float) {} +PD_REGISTER_STRUCT_KERNEL( + lrn_grad, GPU, ALL_LAYOUT, ops::LRNGradKernel, float) {} diff --git a/paddle/fluid/operators/lrn_op.h b/paddle/fluid/operators/lrn_op.h index b772aa82e9d7ea3057339f4fa24db1239d8da6c9..15ebb4df74f47dc284aa3ae2746a5692d99f1fa6 100644 --- a/paddle/fluid/operators/lrn_op.h +++ b/paddle/fluid/operators/lrn_op.h @@ -43,7 +43,7 @@ struct LRNFunctor { const DataLayout data_layout = DataLayout::kAnyLayout); }; -template +template class LRNKernel : public framework::OpKernel { public: // f(x) = x * ( k + alpha * SUM((x)^2) )^(-beta) @@ -136,7 +136,7 @@ struct LRNGradFunctor { * The upper and lower is the same as forward. The logic of the sum * is also the same as forward. */ -template +template class LRNGradKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { diff --git a/paddle/fluid/operators/lstm_op.cc b/paddle/fluid/operators/lstm_op.cc index 7250cf65e488ed6c5626c5149c33081625f19d70..d7734e57ee4921ebd75fc189298cdbe4a8912a9c 100644 --- a/paddle/fluid/operators/lstm_op.cc +++ b/paddle/fluid/operators/lstm_op.cc @@ -358,9 +358,8 @@ REGISTER_OPERATOR(lstm, ops::LSTMGradOpMaker, ops::LSTMGradOpMaker); REGISTER_OPERATOR(lstm_grad, ops::LSTMGradOp); -REGISTER_OP_CPU_KERNEL(lstm, - ops::LSTMKernel, - ops::LSTMKernel); -REGISTER_OP_CPU_KERNEL(lstm_grad, - ops::LSTMGradKernel, - ops::LSTMGradKernel); + +PD_REGISTER_STRUCT_KERNEL( + lstm, CPU, ALL_LAYOUT, ops::LSTMKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + lstm_grad, CPU, ALL_LAYOUT, ops::LSTMGradKernel, float, double) {} diff --git a/paddle/fluid/operators/lstm_op.cu.cc b/paddle/fluid/operators/lstm_op.cu.cc index 13a0ded14b4ea1f7580ef42941d83401824d1bd5..b06521088a95a29cee3ad51074e6b9290e2ee8dd 100644 --- a/paddle/fluid/operators/lstm_op.cu.cc +++ b/paddle/fluid/operators/lstm_op.cu.cc @@ -15,9 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/lstm_op.h" namespace ops = paddle::operators; -REGISTER_OP_CUDA_KERNEL(lstm, - ops::LSTMKernel, - ops::LSTMKernel); -REGISTER_OP_CUDA_KERNEL(lstm_grad, - ops::LSTMGradKernel, - ops::LSTMGradKernel); +PD_REGISTER_STRUCT_KERNEL( + lstm, GPU, ALL_LAYOUT, ops::LSTMKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + lstm_grad, GPU, ALL_LAYOUT, ops::LSTMGradKernel, float, double) {} diff --git a/paddle/fluid/operators/lstm_op.h b/paddle/fluid/operators/lstm_op.h index cba587815657a04a5f99e7b66f332f6a258052be..0e068c47647e3df7cd443850fa85b97db0867ed6 100644 --- a/paddle/fluid/operators/lstm_op.h +++ b/paddle/fluid/operators/lstm_op.h @@ -35,7 +35,7 @@ inline void ReorderInitState(const DeviceContext& ctx, row_shuffle(ctx, src, index_lod, dst, indexed_src); } -template +template class LSTMKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { @@ -197,7 +197,7 @@ class LSTMKernel : public framework::OpKernel { } }; -template +template class LSTMGradKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { diff --git a/paddle/fluid/operators/lstm_unit_op.cc b/paddle/fluid/operators/lstm_unit_op.cc index dab7164fad13702b13c584751313118ce7f9b55a..bbe5504b98e39b12d008d015babe3f17fdb80a71 100644 --- a/paddle/fluid/operators/lstm_unit_op.cc +++ b/paddle/fluid/operators/lstm_unit_op.cc @@ -142,10 +142,8 @@ REGISTER_OPERATOR(lstm_unit, ops::LstmUnitGradOpMaker, ops::LstmUnitGradOpMaker); REGISTER_OPERATOR(lstm_unit_grad, ops::LstmUnitGradOp); -REGISTER_OP_CPU_KERNEL(lstm_unit, - ops::LstmUnitKernel, - ops::LstmUnitKernel); -REGISTER_OP_CPU_KERNEL( - lstm_unit_grad, - ops::LstmUnitGradKernel, - ops::LstmUnitGradKernel); + +PD_REGISTER_STRUCT_KERNEL( + lstm_unit, CPU, ALL_LAYOUT, ops::LstmUnitKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + lstm_unit_grad, CPU, ALL_LAYOUT, ops::LstmUnitGradKernel, float, double) {} diff --git a/paddle/fluid/operators/lstm_unit_op.cu b/paddle/fluid/operators/lstm_unit_op.cu index ffc6e42587f1ceeb04d06d719c0717ce404d252b..b1c9d035a8cb5dbeab64839721d60cf108811295 100644 --- a/paddle/fluid/operators/lstm_unit_op.cu +++ b/paddle/fluid/operators/lstm_unit_op.cu @@ -98,7 +98,7 @@ __global__ void LSTMUnitGradientKernel(const int nthreads, } } -template +template class LstmUnitOpCUDAKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { @@ -131,7 +131,7 @@ class LstmUnitOpCUDAKernel : public framework::OpKernel { } }; -template +template class LstmUnitGradOpCUDAKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { @@ -183,9 +183,11 @@ class LstmUnitGradOpCUDAKernel : public framework::OpKernel { } // namespace paddle namespace ops = paddle::operators; -REGISTER_OP_CUDA_KERNEL(lstm_unit, - ops::LstmUnitOpCUDAKernel, - ops::LstmUnitOpCUDAKernel); -REGISTER_OP_CUDA_KERNEL(lstm_unit_grad, - ops::LstmUnitGradOpCUDAKernel, - ops::LstmUnitGradOpCUDAKernel); +PD_REGISTER_STRUCT_KERNEL( + lstm_unit, GPU, ALL_LAYOUT, ops::LstmUnitOpCUDAKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL(lstm_unit_grad, + GPU, + ALL_LAYOUT, + ops::LstmUnitGradOpCUDAKernel, + float, + double) {} diff --git a/paddle/fluid/operators/lstm_unit_op.h b/paddle/fluid/operators/lstm_unit_op.h index abb2eb1620dbe484bb6b2b5927bb274b24f9946b..0621741b885fb7cd2bbc90b07ab3a6c1e4e27f08 100644 --- a/paddle/fluid/operators/lstm_unit_op.h +++ b/paddle/fluid/operators/lstm_unit_op.h @@ -33,7 +33,7 @@ inline T tanh(T x) { return 2. * sigmoid(2. * x) - 1.; } -template +template class LstmUnitKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { @@ -78,7 +78,7 @@ class LstmUnitKernel : public framework::OpKernel { } }; -template +template class LstmUnitGradKernel : public framework::OpKernel { public: void Compute(const framework::ExecutionContext& ctx) const override { diff --git a/paddle/fluid/operators/lstmp_op.cc b/paddle/fluid/operators/lstmp_op.cc index 63cf07e35b7cb9c0eb50cddb4acc450597375efc..44e9a698beee71b4312c64b5789580eeda100492 100644 --- a/paddle/fluid/operators/lstmp_op.cc +++ b/paddle/fluid/operators/lstmp_op.cc @@ -405,9 +405,7 @@ REGISTER_OPERATOR(lstmp, ops::LSTMPGradMaker, ops::LSTMPGradMaker); REGISTER_OPERATOR(lstmp_grad, ops::LSTMPGradOp); -REGISTER_OP_CPU_KERNEL(lstmp, - ops::LSTMPKernel, - ops::LSTMPKernel); -REGISTER_OP_CPU_KERNEL(lstmp_grad, - ops::LSTMPGradKernel, - ops::LSTMPGradKernel); +PD_REGISTER_STRUCT_KERNEL( + lstmp, CPU, ALL_LAYOUT, ops::LSTMPKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + lstmp_grad, CPU, ALL_LAYOUT, ops::LSTMPGradKernel, float, double) {} diff --git a/paddle/fluid/operators/lstmp_op.cu b/paddle/fluid/operators/lstmp_op.cu index 8614eaf5d4959580186c2ad289e33f3b5726d7a3..5559d09f1b9ba96304876520b3311ce9eec4ed99 100644 --- a/paddle/fluid/operators/lstmp_op.cu +++ b/paddle/fluid/operators/lstmp_op.cu @@ -15,9 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/lstmp_op.h" namespace ops = paddle::operators; -REGISTER_OP_CUDA_KERNEL(lstmp, - ops::LSTMPKernel, - ops::LSTMPKernel); -REGISTER_OP_CUDA_KERNEL(lstmp_grad, - ops::LSTMPGradKernel, - ops::LSTMPGradKernel); +PD_REGISTER_STRUCT_KERNEL( + lstmp, GPU, ALL_LAYOUT, ops::LSTMPKernel, float, double) {} +PD_REGISTER_STRUCT_KERNEL( + lstmp_grad, GPU, ALL_LAYOUT, ops::LSTMPGradKernel, float, double) {} diff --git a/paddle/fluid/operators/lstmp_op.h b/paddle/fluid/operators/lstmp_op.h index 90e3072dbf97ebbfb6f0bbcbe375d6327b94db3f..fd9032c730af849e6ed2b31a84644e470dd03bb9 100644 --- a/paddle/fluid/operators/lstmp_op.h +++ b/paddle/fluid/operators/lstmp_op.h @@ -78,7 +78,7 @@ inline void ReorderInitState(const DeviceContext& ctx, row_shuffle(ctx, src, index, dst, indexed_src); } -template +template class LSTMPKernel : public framework::OpKernel { public: template @@ -279,7 +279,7 @@ class LSTMPKernel : public framework::OpKernel { } }; -template +template class LSTMPGradKernel : public framework::OpKernel { public: template