Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
09da1c4c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
09da1c4c
编写于
4月 07, 2023
作者:
Y
YuanRisheng
提交者:
GitHub
4月 07, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unify kernel (#52594)
上级
5662adcc
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
95 addition
and
67 deletion
+95
-67
paddle/fluid/operators/push_dense_op.cc
paddle/fluid/operators/push_dense_op.cc
+2
-1
paddle/fluid/operators/push_dense_op.h
paddle/fluid/operators/push_dense_op.h
+1
-1
paddle/fluid/operators/pyramid_hash_op.cc
paddle/fluid/operators/pyramid_hash_op.cc
+10
-7
paddle/fluid/operators/quantize_linear_op.cc
paddle/fluid/operators/quantize_linear_op.cc
+9
-6
paddle/fluid/operators/quantize_linear_op.cu
paddle/fluid/operators/quantize_linear_op.cu
+15
-9
paddle/fluid/operators/quantize_linear_op.h
paddle/fluid/operators/quantize_linear_op.h
+2
-2
paddle/fluid/operators/random_crop_op.cc
paddle/fluid/operators/random_crop_op.cc
+9
-8
paddle/fluid/operators/random_crop_op.cu
paddle/fluid/operators/random_crop_op.cu
+10
-8
paddle/fluid/operators/random_crop_op.h
paddle/fluid/operators/random_crop_op.h
+1
-1
paddle/fluid/operators/random_routing_op.cc
paddle/fluid/operators/random_routing_op.cc
+6
-3
paddle/fluid/operators/random_routing_op.cu
paddle/fluid/operators/random_routing_op.cu
+8
-5
paddle/fluid/operators/random_routing_op.h
paddle/fluid/operators/random_routing_op.h
+1
-1
paddle/fluid/operators/rank_attention_op.cc
paddle/fluid/operators/rank_attention_op.cc
+2
-3
paddle/fluid/operators/rank_attention_op.cu
paddle/fluid/operators/rank_attention_op.cu
+15
-9
paddle/fluid/operators/rank_attention_op.h
paddle/fluid/operators/rank_attention_op.h
+1
-1
paddle/fluid/operators/read_file_op.cc
paddle/fluid/operators/read_file_op.cc
+3
-2
未找到文件。
paddle/fluid/operators/push_dense_op.cc
浏览文件 @
09da1c4c
...
...
@@ -70,4 +70,5 @@ REGISTER_OPERATOR(
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
ops
::
PushDenseNoNeedBufferVarsInferer
);
REGISTER_OP_CPU_KERNEL
(
push_dense
,
ops
::
PushDenseCPUKernel
<
float
>
)
PD_REGISTER_STRUCT_KERNEL
(
push_dense
,
CPU
,
ALL_LAYOUT
,
ops
::
PushDenseCPUKernel
,
float
)
{}
paddle/fluid/operators/push_dense_op.h
浏览文件 @
09da1c4c
...
...
@@ -60,7 +60,7 @@ void PushDenseFunctor(const framework::ExecutionContext& ctx) {
#endif
}
template
<
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
PushDenseCPUKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
...
...
paddle/fluid/operators/pyramid_hash_op.cc
浏览文件 @
09da1c4c
...
...
@@ -232,7 +232,7 @@ class PyramidHashOP : public framework::OperatorWithKernel {
}
};
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
CPUPyramidHashOPKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
bool
should_use_term
(
math
::
bloomfilter
*
_filter
,
...
...
@@ -492,7 +492,7 @@ class PyramidHashGradOpMaker : public framework::SingleGradOpMaker<T> {
}
};
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
CPUPyramidHashOPGradKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
hash_embedding_bp
(
const
T
*
hash_id
,
...
...
@@ -584,8 +584,11 @@ REGISTER_OPERATOR(pyramid_hash,
ops
::
PyramidHashGradOpMaker
<
paddle
::
imperative
::
OpBase
>
);
REGISTER_OPERATOR
(
pyramid_hash_grad
,
ops
::
PyramidHashOpGrad
);
REGISTER_OP_CPU_KERNEL
(
pyramid_hash
,
ops
::
CPUPyramidHashOPKernel
<
phi
::
CPUContext
,
float
>
,
ops
::
CPUPyramidHashOPKernel
<
phi
::
CPUContext
,
int8_t
>
);
REGISTER_OP_CPU_KERNEL
(
pyramid_hash_grad
,
ops
::
CPUPyramidHashOPGradKernel
<
phi
::
CPUContext
,
float
>
);
PD_REGISTER_STRUCT_KERNEL
(
pyramid_hash
,
CPU
,
ALL_LAYOUT
,
ops
::
CPUPyramidHashOPKernel
,
float
,
int8_t
)
{
}
PD_REGISTER_STRUCT_KERNEL
(
pyramid_hash_grad
,
CPU
,
ALL_LAYOUT
,
ops
::
CPUPyramidHashOPGradKernel
,
float
)
{}
paddle/fluid/operators/quantize_linear_op.cc
浏览文件 @
09da1c4c
...
...
@@ -222,7 +222,6 @@ $$0 \leq c \lt \ the\ channel\ number\ of\ X$$
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
using
CPU
=
phi
::
CPUContext
;
REGISTER_OPERATOR
(
quantize_linear
,
...
...
@@ -231,7 +230,8 @@ REGISTER_OPERATOR(
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
);
REGISTER_OP_CPU_KERNEL
(
quantize_linear
,
ops
::
QuantizeLinearKernel
<
CPU
,
float
>
);
PD_REGISTER_STRUCT_KERNEL
(
quantize_linear
,
CPU
,
ALL_LAYOUT
,
ops
::
QuantizeLinearKernel
,
float
)
{}
REGISTER_OPERATOR
(
dequantize_linear
,
...
...
@@ -240,7 +240,10 @@ REGISTER_OPERATOR(
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
);
REGISTER_OP_CPU_KERNEL
(
dequantize_linear
,
ops
::
DeQuantizeLinearKernel
<
CPU
,
float
>
,
ops
::
DeQuantizeLinearKernel
<
CPU
,
int8_t
>
,
ops
::
DeQuantizeLinearKernel
<
CPU
,
double
>
);
PD_REGISTER_STRUCT_KERNEL
(
dequantize_linear
,
CPU
,
ALL_LAYOUT
,
ops
::
DeQuantizeLinearKernel
,
float
,
int8_t
,
double
)
{}
paddle/fluid/operators/quantize_linear_op.cu
浏览文件 @
09da1c4c
...
...
@@ -123,12 +123,18 @@ template struct ChannelDequantizeFunctorV2<phi::GPUContext, double>;
namespace
ops
=
paddle
::
operators
;
using
CUDA
=
phi
::
GPUContext
;
REGISTER_OP_CUDA_KERNEL
(
dequantize_linear
,
ops
::
DeQuantizeLinearKernel
<
CUDA
,
float
>
,
ops
::
DeQuantizeLinearKernel
<
CUDA
,
float16
>
,
ops
::
DeQuantizeLinearKernel
<
CUDA
,
int8_t
>
,
ops
::
DeQuantizeLinearKernel
<
CUDA
,
double
>
);
REGISTER_OP_CUDA_KERNEL
(
quantize_linear
,
ops
::
QuantizeLinearKernel
<
CUDA
,
float
>
,
ops
::
QuantizeLinearKernel
<
CUDA
,
float16
>
);
PD_REGISTER_STRUCT_KERNEL
(
dequantize_linear
,
GPU
,
ALL_LAYOUT
,
ops
::
DeQuantizeLinearKernel
,
float
,
float16
,
int8_t
,
double
)
{}
PD_REGISTER_STRUCT_KERNEL
(
quantize_linear
,
GPU
,
ALL_LAYOUT
,
ops
::
QuantizeLinearKernel
,
float
,
float16
)
{}
paddle/fluid/operators/quantize_linear_op.h
浏览文件 @
09da1c4c
...
...
@@ -47,7 +47,7 @@ struct ChannelDequantizeFunctorV2 {
phi
::
DenseTensor
*
out
);
};
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
QuantizeLinearKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
...
...
@@ -130,7 +130,7 @@ class QuantizeLinearKernel : public framework::OpKernel<T> {
}
};
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
DeQuantizeLinearKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
template
<
typename
D
>
...
...
paddle/fluid/operators/random_crop_op.cc
浏览文件 @
09da1c4c
...
...
@@ -96,11 +96,12 @@ REGISTER_OPERATOR(
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
);
template
<
typename
T
>
using
Kernel
=
ops
::
RandomCropKernel
<
phi
::
CPUContext
,
T
>
;
REGISTER_OP_CPU_KERNEL
(
random_crop
,
Kernel
<
float
>
,
Kernel
<
int
>
,
Kernel
<
double
>
,
Kernel
<
uint8_t
>
,
Kernel
<
int16_t
>
);
PD_REGISTER_STRUCT_KERNEL
(
random_crop
,
CPU
,
ALL_LAYOUT
,
ops
::
RandomCropKernel
,
float
,
int
,
double
,
uint8_t
,
int16_t
)
{}
paddle/fluid/operators/random_crop_op.cu
浏览文件 @
09da1c4c
...
...
@@ -15,11 +15,13 @@
#include "paddle/fluid/operators/random_crop_op.h"
namespace
ops
=
paddle
::
operators
;
template
<
typename
T
>
using
Kernel
=
ops
::
RandomCropKernel
<
phi
::
GPUContext
,
T
>
;
REGISTER_OP_CUDA_KERNEL
(
random_crop
,
Kernel
<
float
>
,
Kernel
<
int
>
,
Kernel
<
double
>
,
Kernel
<
uint8_t
>
,
Kernel
<
int16_t
>
);
PD_REGISTER_STRUCT_KERNEL
(
random_crop
,
GPU
,
ALL_LAYOUT
,
ops
::
RandomCropKernel
,
float
,
int
,
double
,
uint8_t
,
int16_t
)
{}
paddle/fluid/operators/random_crop_op.h
浏览文件 @
09da1c4c
...
...
@@ -176,7 +176,7 @@ struct RandomCropFunctor {
}
};
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
RandomCropKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
virtual
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
{
...
...
paddle/fluid/operators/random_routing_op.cc
浏览文件 @
09da1c4c
...
...
@@ -98,6 +98,9 @@ REGISTER_OPERATOR(
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
ops
::
RandomRoutingInplaceInferer
)
REGISTER_OP_CPU_KERNEL
(
random_routing
,
ops
::
RandomRoutingOpCPUKernel
<
float
>
,
ops
::
RandomRoutingOpCPUKernel
<
double
>
);
PD_REGISTER_STRUCT_KERNEL
(
random_routing
,
CPU
,
ALL_LAYOUT
,
ops
::
RandomRoutingOpCPUKernel
,
float
,
double
)
{}
paddle/fluid/operators/random_routing_op.cu
浏览文件 @
09da1c4c
...
...
@@ -47,7 +47,7 @@ __global__ void random_routing_kernel(int64_t* data,
}
}
template
<
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
RandomRoutingOpCUDAKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
override
{
...
...
@@ -82,7 +82,10 @@ class RandomRoutingOpCUDAKernel : public framework::OpKernel<T> {
namespace
ops
=
paddle
::
operators
;
namespace
plat
=
paddle
::
platform
;
REGISTER_OP_CUDA_KERNEL
(
random_routing
,
ops
::
RandomRoutingOpCUDAKernel
<
float
>
,
ops
::
RandomRoutingOpCUDAKernel
<
double
>
,
ops
::
RandomRoutingOpCUDAKernel
<
plat
::
float16
>
);
PD_REGISTER_STRUCT_KERNEL
(
random_routing
,
GPU
,
ALL_LAYOUT
,
ops
::
RandomRoutingOpCUDAKernel
,
float
,
double
,
plat
::
float16
)
{}
paddle/fluid/operators/random_routing_op.h
浏览文件 @
09da1c4c
...
...
@@ -24,7 +24,7 @@
namespace
paddle
{
namespace
operators
{
template
<
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
RandomRoutingOpCPUKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
...
...
paddle/fluid/operators/rank_attention_op.cc
浏览文件 @
09da1c4c
...
...
@@ -192,9 +192,8 @@ REGISTER_OPERATOR(rank_attention_grad,
ops
::
RankAttentionGradOp
,
ops
::
RankAttentionGradOpNoNeedBufferVarsInference
);
REGISTER_OP_CPU_KERNEL
(
rank_attention
,
ops
::
RankAttentionKernel
<
phi
::
CPUContext
,
float
>
,
ops
::
RankAttentionKernel
<
phi
::
CPUContext
,
double
>
);
PD_REGISTER_STRUCT_KERNEL
(
rank_attention
,
CPU
,
ALL_LAYOUT
,
ops
::
RankAttentionKernel
,
float
,
double
)
{}
REGISTER_OP_VERSION
(
rank_attention
)
.
AddCheckpoint
(
...
...
paddle/fluid/operators/rank_attention_op.cu
浏览文件 @
09da1c4c
...
...
@@ -24,7 +24,7 @@ limitations under the License. */
namespace
paddle
{
namespace
operators
{
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
RankAttentionCUDAKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
...
...
@@ -150,7 +150,7 @@ class RankAttentionCUDAKernel : public framework::OpKernel<T> {
}
};
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
RankAttentionGradOpCUDAKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
...
...
@@ -243,10 +243,16 @@ class RankAttentionGradOpCUDAKernel : public framework::OpKernel<T> {
namespace
ops
=
paddle
::
operators
;
using
GPUCtx
=
phi
::
GPUContext
;
REGISTER_OP_CUDA_KERNEL
(
rank_attention
,
ops
::
RankAttentionCUDAKernel
<
GPUCtx
,
float
>
,
ops
::
RankAttentionCUDAKernel
<
GPUCtx
,
double
>
);
REGISTER_OP_CUDA_KERNEL
(
rank_attention_grad
,
ops
::
RankAttentionGradOpCUDAKernel
<
GPUCtx
,
float
>
,
ops
::
RankAttentionGradOpCUDAKernel
<
GPUCtx
,
double
>
);
PD_REGISTER_STRUCT_KERNEL
(
rank_attention
,
GPU
,
ALL_LAYOUT
,
ops
::
RankAttentionCUDAKernel
,
float
,
double
)
{}
PD_REGISTER_STRUCT_KERNEL
(
rank_attention_grad
,
GPU
,
ALL_LAYOUT
,
ops
::
RankAttentionGradOpCUDAKernel
,
float
,
double
)
{}
paddle/fluid/operators/rank_attention_op.h
浏览文件 @
09da1c4c
...
...
@@ -19,7 +19,7 @@ limitations under the License. */
namespace
paddle
{
namespace
operators
{
template
<
typename
DeviceContext
,
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
RankAttentionKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
...
...
paddle/fluid/operators/read_file_op.cc
浏览文件 @
09da1c4c
...
...
@@ -24,7 +24,7 @@
namespace
paddle
{
namespace
operators
{
template
<
typename
T
>
template
<
typename
T
,
typename
DeviceContext
>
class
CPUReadFileKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
...
...
@@ -92,4 +92,5 @@ REGISTER_OPERATOR(
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
)
REGISTER_OP_CPU_KERNEL
(
read_file
,
ops
::
CPUReadFileKernel
<
uint8_t
>
)
PD_REGISTER_STRUCT_KERNEL
(
read_file
,
CPU
,
ALL_LAYOUT
,
ops
::
CPUReadFileKernel
,
uint8_t
)
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录