未验证 提交 a176a07e 编写于 作者: H huangjiyi 提交者: GitHub

Register fluid kerenls to phi [part 8] (#53032)

* update

* fix bug
上级 e0c14fdf
......@@ -269,9 +269,11 @@ REGISTER_OPERATOR(sequence_conv_grad,
ops::SequenceConvGradOp,
ops::SequenceConvGradNoNeedBufferVarsInference);
REGISTER_OP_CPU_KERNEL(sequence_conv,
ops::SequenceConvKernel<phi::CPUContext, float>,
ops::SequenceConvKernel<phi::CPUContext, double>);
REGISTER_OP_CPU_KERNEL(sequence_conv_grad,
ops::SequenceConvGradKernel<phi::CPUContext, float>,
ops::SequenceConvGradKernel<phi::CPUContext, double>);
PD_REGISTER_STRUCT_KERNEL(
sequence_conv, CPU, ALL_LAYOUT, ops::SequenceConvKernel, float, double) {}
PD_REGISTER_STRUCT_KERNEL(sequence_conv_grad,
CPU,
ALL_LAYOUT,
ops::SequenceConvGradKernel,
float,
double) {}
......@@ -15,9 +15,11 @@ limitations under the License. */
#include "paddle/fluid/operators/sequence_ops/sequence_conv_op.h"
namespace ops = paddle::operators;
REGISTER_OP_CUDA_KERNEL(sequence_conv,
ops::SequenceConvKernel<phi::GPUContext, float>,
ops::SequenceConvKernel<phi::GPUContext, double>);
REGISTER_OP_CUDA_KERNEL(sequence_conv_grad,
ops::SequenceConvGradKernel<phi::GPUContext, float>,
ops::SequenceConvGradKernel<phi::GPUContext, double>);
PD_REGISTER_STRUCT_KERNEL(
sequence_conv, GPU, ALL_LAYOUT, ops::SequenceConvKernel, float, double) {}
PD_REGISTER_STRUCT_KERNEL(sequence_conv_grad,
GPU,
ALL_LAYOUT,
ops::SequenceConvGradKernel,
float,
double) {}
......@@ -22,7 +22,7 @@ limitations under the License. */
namespace paddle {
namespace operators {
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceConvKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& context) const override {
......@@ -85,7 +85,7 @@ class SequenceConvKernel : public framework::OpKernel<T> {
}
};
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceConvGradKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& context) const override {
......
......@@ -88,6 +88,9 @@ namespace ops = paddle::operators;
REGISTER_OP_WITHOUT_GRADIENT(sequence_enumerate,
ops::SequenceEnumerateOp,
ops::SequenceEnumerateOpMaker);
REGISTER_OP_CPU_KERNEL(sequence_enumerate,
ops::SequenceEnumerateKernel<phi::CPUContext, int32_t>,
ops::SequenceEnumerateKernel<phi::CPUContext, int64_t>);
PD_REGISTER_STRUCT_KERNEL(sequence_enumerate,
CPU,
ALL_LAYOUT,
ops::SequenceEnumerateKernel,
int32_t,
int64_t) {}
......@@ -47,7 +47,7 @@ __global__ void CalcOutPut(const T* in_data,
}
}
template <typename T>
template <typename T, typename DeviceContext>
class SequenceEnumerateOpCUDAKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& context) const override {
......@@ -91,7 +91,10 @@ class SequenceEnumerateOpCUDAKernel : public framework::OpKernel<T> {
} // namespace operators
} // namespace paddle
REGISTER_OP_CUDA_KERNEL(
sequence_enumerate,
paddle::operators::SequenceEnumerateOpCUDAKernel<int32_t>,
paddle::operators::SequenceEnumerateOpCUDAKernel<int64_t>);
namespace ops = paddle::operators;
PD_REGISTER_STRUCT_KERNEL(sequence_enumerate,
GPU,
ALL_LAYOUT,
ops::SequenceEnumerateOpCUDAKernel,
int32_t,
int64_t) {}
......@@ -19,7 +19,7 @@
namespace paddle {
namespace operators {
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceEnumerateKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& context) const override {
......
......@@ -98,6 +98,9 @@ namespace ops = paddle::operators;
REGISTER_OP_WITHOUT_GRADIENT(sequence_erase,
ops::SequenceEraseOp,
ops::SequenceEraseOpMaker);
REGISTER_OP_CPU_KERNEL(sequence_erase,
ops::SequenceEraseKernel<phi::CPUContext, int32_t>,
ops::SequenceEraseKernel<phi::CPUContext, int64_t>);
PD_REGISTER_STRUCT_KERNEL(sequence_erase,
CPU,
ALL_LAYOUT,
ops::SequenceEraseKernel,
int32_t,
int64_t) {}
......@@ -62,7 +62,7 @@ __global__ void SetOutput(const T* in_dat,
}
}
template <typename T>
template <typename T, typename DeviceContext>
class SequenceEraseOpCUDAKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& ctx) const override {
......@@ -129,6 +129,10 @@ class SequenceEraseOpCUDAKernel : public framework::OpKernel<T> {
} // namespace operators
} // namespace paddle
REGISTER_OP_CUDA_KERNEL(sequence_erase,
paddle::operators::SequenceEraseOpCUDAKernel<int32_t>,
paddle::operators::SequenceEraseOpCUDAKernel<int64_t>);
namespace ops = paddle::operators;
PD_REGISTER_STRUCT_KERNEL(sequence_erase,
GPU,
ALL_LAYOUT,
ops::SequenceEraseOpCUDAKernel,
int32_t,
int64_t) {}
......@@ -21,7 +21,7 @@ limitations under the License. */
namespace paddle {
namespace operators {
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceEraseKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& ctx) const override {
......
......@@ -209,14 +209,19 @@ REGISTER_OPERATOR(
REGISTER_OPERATOR(sequence_expand_as_grad,
ops::SequenceExpandAsOpGrad,
ops::SequenceExpandAsGradOpNoNeedBufferVarsInferer);
REGISTER_OP_CPU_KERNEL(sequence_expand_as,
ops::SequenceExpandAsKernel<phi::CPUContext, float>,
ops::SequenceExpandAsKernel<phi::CPUContext, double>,
ops::SequenceExpandAsKernel<phi::CPUContext, int>,
ops::SequenceExpandAsKernel<phi::CPUContext, int64_t>);
REGISTER_OP_CPU_KERNEL(
sequence_expand_as_grad,
ops::SequenceExpandAsGradKernel<phi::CPUContext, float>,
ops::SequenceExpandAsGradKernel<phi::CPUContext, double>,
ops::SequenceExpandAsGradKernel<phi::CPUContext, int>,
ops::SequenceExpandAsGradKernel<phi::CPUContext, int64_t>);
PD_REGISTER_STRUCT_KERNEL(sequence_expand_as,
CPU,
ALL_LAYOUT,
ops::SequenceExpandAsKernel,
float,
double,
int,
int64_t) {}
PD_REGISTER_STRUCT_KERNEL(sequence_expand_as_grad,
CPU,
ALL_LAYOUT,
ops::SequenceExpandAsGradKernel,
float,
double,
int,
int64_t) {}
......@@ -130,14 +130,19 @@ struct SequenceExpandAsGradFunctor<phi::GPUContext, T> {
} // namespace paddle
namespace ops = paddle::operators;
REGISTER_OP_CUDA_KERNEL(sequence_expand_as,
ops::SequenceExpandAsKernel<phi::GPUContext, float>,
ops::SequenceExpandAsKernel<phi::GPUContext, double>,
ops::SequenceExpandAsKernel<phi::GPUContext, int>,
ops::SequenceExpandAsKernel<phi::GPUContext, int64_t>);
REGISTER_OP_CUDA_KERNEL(
sequence_expand_as_grad,
ops::SequenceExpandAsGradKernel<phi::GPUContext, float>,
ops::SequenceExpandAsGradKernel<phi::GPUContext, double>,
ops::SequenceExpandAsGradKernel<phi::GPUContext, int>,
ops::SequenceExpandAsGradKernel<phi::GPUContext, int64_t>);
PD_REGISTER_STRUCT_KERNEL(sequence_expand_as,
GPU,
ALL_LAYOUT,
ops::SequenceExpandAsKernel,
float,
double,
int,
int64_t) {}
PD_REGISTER_STRUCT_KERNEL(sequence_expand_as_grad,
GPU,
ALL_LAYOUT,
ops::SequenceExpandAsGradKernel,
float,
double,
int,
int64_t) {}
......@@ -67,7 +67,7 @@ struct SequenceExpandAsFunctor<phi::CPUContext, T> {
}
};
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceExpandAsKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext &context) const override {
......@@ -144,7 +144,7 @@ struct SequenceExpandAsGradFunctor<phi::CPUContext, T> {
}
};
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceExpandAsGradKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext &context) const override {
......
......@@ -281,13 +281,19 @@ REGISTER_OPERATOR(sequence_expand,
REGISTER_OPERATOR(sequence_expand_grad,
ops::SequenceExpandOpGrad,
ops::SequenceExpandGradOpNoNeedBufferVarsInferer);
REGISTER_OP_CPU_KERNEL(sequence_expand,
ops::SequenceExpandKernel<phi::CPUContext, float>,
ops::SequenceExpandKernel<phi::CPUContext, double>,
ops::SequenceExpandKernel<phi::CPUContext, int>,
ops::SequenceExpandKernel<phi::CPUContext, int64_t>);
REGISTER_OP_CPU_KERNEL(sequence_expand_grad,
ops::SequenceExpandGradKernel<phi::CPUContext, float>,
ops::SequenceExpandGradKernel<phi::CPUContext, double>,
ops::SequenceExpandGradKernel<phi::CPUContext, int>,
ops::SequenceExpandGradKernel<phi::CPUContext, int64_t>);
PD_REGISTER_STRUCT_KERNEL(sequence_expand,
CPU,
ALL_LAYOUT,
ops::SequenceExpandKernel,
float,
double,
int,
int64_t) {}
PD_REGISTER_STRUCT_KERNEL(sequence_expand_grad,
CPU,
ALL_LAYOUT,
ops::SequenceExpandGradKernel,
float,
double,
int,
int64_t) {}
......@@ -227,14 +227,19 @@ struct SequenceExpandGradFunctor<phi::GPUContext, T> {
} // namespace paddle
namespace ops = paddle::operators;
REGISTER_OP_CUDA_KERNEL(sequence_expand,
ops::SequenceExpandKernel<phi::GPUContext, float>,
ops::SequenceExpandKernel<phi::GPUContext, double>,
ops::SequenceExpandKernel<phi::GPUContext, int>,
ops::SequenceExpandKernel<phi::GPUContext, int64_t>);
REGISTER_OP_CUDA_KERNEL(
sequence_expand_grad,
ops::SequenceExpandGradKernel<phi::GPUContext, float>,
ops::SequenceExpandGradKernel<phi::GPUContext, double>,
ops::SequenceExpandGradKernel<phi::GPUContext, int>,
ops::SequenceExpandGradKernel<phi::GPUContext, int64_t>);
PD_REGISTER_STRUCT_KERNEL(sequence_expand,
GPU,
ALL_LAYOUT,
ops::SequenceExpandKernel,
float,
double,
int,
int64_t) {}
PD_REGISTER_STRUCT_KERNEL(sequence_expand_grad,
GPU,
ALL_LAYOUT,
ops::SequenceExpandGradKernel,
float,
double,
int,
int64_t) {}
......@@ -81,7 +81,7 @@ struct SequenceExpandFunctor<phi::CPUContext, T> {
}
};
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceExpandKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& context) const override {
......@@ -185,7 +185,7 @@ struct SequenceExpandGradFunctor<phi::CPUContext, T> {
}
};
template <typename DeviceContext, typename T>
template <typename T, typename DeviceContext>
class SequenceExpandGradKernel : public framework::OpKernel<T> {
public:
void Compute(const framework::ExecutionContext& context) const override {
......
......@@ -102,9 +102,12 @@ REGISTER_OPERATOR(
paddle::framework::EmptyGradOpMaker<paddle::framework::OpDesc>,
paddle::framework::EmptyGradOpMaker<paddle::imperative::OpBase>);
REGISTER_OP_CPU_KERNEL(
sequence_mask,
paddle::operators::SequenceMaskKernel<phi::CPUContext, int>,
paddle::operators::SequenceMaskKernel<phi::CPUContext, int64_t>,
paddle::operators::SequenceMaskKernel<phi::CPUContext, float>,
paddle::operators::SequenceMaskKernel<phi::CPUContext, double>);
namespace ops = paddle::operators;
PD_REGISTER_STRUCT_KERNEL(sequence_mask,
CPU,
ALL_LAYOUT,
ops::SequenceMaskKernel,
float,
double,
int,
int64_t) {}
......@@ -14,9 +14,12 @@
#include "paddle/fluid/operators/sequence_ops/sequence_mask_op.h"
REGISTER_OP_CUDA_KERNEL(
sequence_mask,
paddle::operators::SequenceMaskKernel<phi::GPUContext, int>,
paddle::operators::SequenceMaskKernel<phi::GPUContext, int64_t>,
paddle::operators::SequenceMaskKernel<phi::GPUContext, float>,
paddle::operators::SequenceMaskKernel<phi::GPUContext, double>);
namespace ops = paddle::operators;
PD_REGISTER_STRUCT_KERNEL(sequence_mask,
GPU,
ALL_LAYOUT,
ops::SequenceMaskKernel,
float,
double,
int,
int64_t) {}
......@@ -69,7 +69,7 @@ struct SequenceMaskFunctor {
int maxlen_;
};
template <typename DeviceContext, typename Tx>
template <typename Tx, typename DeviceContext>
class SequenceMaskKernel : public framework::OpKernel<Tx> {
public:
void Compute(const framework::ExecutionContext &ctx) const override {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册