Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
9171f737
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9171f737
编写于
10月 24, 2019
作者:
D
danleifeng
提交者:
gongweibao
10月 24, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix fp16 grid_size for size=1; test=develop (#20812)
上级
cd1c4043
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
20 deletion
+24
-20
paddle/fluid/operators/elementwise/elementwise_add_op.cu
paddle/fluid/operators/elementwise/elementwise_add_op.cu
+6
-5
paddle/fluid/operators/elementwise/elementwise_div_op.cu
paddle/fluid/operators/elementwise/elementwise_div_op.cu
+6
-5
paddle/fluid/operators/elementwise/elementwise_mul_op.cu
paddle/fluid/operators/elementwise/elementwise_mul_op.cu
+6
-5
paddle/fluid/operators/elementwise/elementwise_sub_op.cu
paddle/fluid/operators/elementwise/elementwise_sub_op.cu
+6
-5
未找到文件。
paddle/fluid/operators/elementwise/elementwise_add_op.cu
浏览文件 @
9171f737
...
@@ -40,8 +40,9 @@ struct SameDimsElemwiseAdd<platform::CUDADeviceContext, platform::float16> {
...
@@ -40,8 +40,9 @@ struct SameDimsElemwiseAdd<platform::CUDADeviceContext, platform::float16> {
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
framework
::
Tensor
*
z
)
{
framework
::
Tensor
*
z
)
{
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
gird_size
=
dim3
(
dim3
grid_size
=
dim3
(((
size
+
1
)
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
(
size
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
const
half
*
x2
=
const
half
*
x2
=
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
...
@@ -49,7 +50,7 @@ struct SameDimsElemwiseAdd<platform::CUDADeviceContext, platform::float16> {
...
@@ -49,7 +50,7 @@ struct SameDimsElemwiseAdd<platform::CUDADeviceContext, platform::float16> {
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
SameDimsElemwiseAddCUDAKernel
<<<
SameDimsElemwiseAddCUDAKernel
<<<
g
ir
d_size
,
block_size
,
0
,
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
x2
,
y2
,
z2
,
size
);
x2
,
y2
,
z2
,
size
);
}
}
...
@@ -78,10 +79,10 @@ elementwise_add_grad(const framework::ExecutionContext& ctx,
...
@@ -78,10 +79,10 @@ elementwise_add_grad(const framework::ExecutionContext& ctx,
framework
::
Tensor
*
dy
)
{
framework
::
Tensor
*
dy
)
{
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
g
ir
d_size
=
dim3
g
ri
d_size
=
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
SimpleElemwiseAddGradCUDAKernel
<
SimpleElemwiseAddGradCUDAKernel
<
T
><<<
g
ir
d_size
,
block_size
,
0
,
T
><<<
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
dout
->
data
<
T
>
(),
size
,
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dout
->
data
<
T
>
(),
size
,
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
...
...
paddle/fluid/operators/elementwise/elementwise_div_op.cu
浏览文件 @
9171f737
...
@@ -41,8 +41,9 @@ struct SameDimsElemwiseDiv<platform::CUDADeviceContext, platform::float16> {
...
@@ -41,8 +41,9 @@ struct SameDimsElemwiseDiv<platform::CUDADeviceContext, platform::float16> {
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
framework
::
Tensor
*
z
)
{
framework
::
Tensor
*
z
)
{
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
gird_size
=
dim3
(
dim3
grid_size
=
dim3
(((
size
+
1
)
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
(
size
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
const
half
*
x2
=
const
half
*
x2
=
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
...
@@ -50,7 +51,7 @@ struct SameDimsElemwiseDiv<platform::CUDADeviceContext, platform::float16> {
...
@@ -50,7 +51,7 @@ struct SameDimsElemwiseDiv<platform::CUDADeviceContext, platform::float16> {
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
SameDimsElemwiseDivCUDAKernel
<<<
SameDimsElemwiseDivCUDAKernel
<<<
g
ir
d_size
,
block_size
,
0
,
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
x2
,
y2
,
z2
,
size
);
x2
,
y2
,
z2
,
size
);
}
}
...
@@ -82,10 +83,10 @@ elementwise_div_grad(const framework::ExecutionContext& ctx,
...
@@ -82,10 +83,10 @@ elementwise_div_grad(const framework::ExecutionContext& ctx,
framework
::
Tensor
*
dy
)
{
framework
::
Tensor
*
dy
)
{
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
g
ir
d_size
=
dim3
g
ri
d_size
=
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
SimpleElemwiseDivGradCUDAKernel
<
SimpleElemwiseDivGradCUDAKernel
<
T
><<<
g
ir
d_size
,
block_size
,
0
,
T
><<<
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
x
->
data
<
T
>
(),
y
->
data
<
T
>
(),
out
->
data
<
T
>
(),
dout
->
data
<
T
>
(),
size
,
x
->
data
<
T
>
(),
y
->
data
<
T
>
(),
out
->
data
<
T
>
(),
dout
->
data
<
T
>
(),
size
,
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
...
...
paddle/fluid/operators/elementwise/elementwise_mul_op.cu
浏览文件 @
9171f737
...
@@ -41,8 +41,9 @@ struct SameDimsElemwiseMul<platform::CUDADeviceContext, platform::float16> {
...
@@ -41,8 +41,9 @@ struct SameDimsElemwiseMul<platform::CUDADeviceContext, platform::float16> {
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
framework
::
Tensor
*
z
)
{
framework
::
Tensor
*
z
)
{
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
gird_size
=
dim3
(
dim3
grid_size
=
dim3
(((
size
+
1
)
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
(
size
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
const
half
*
x2
=
const
half
*
x2
=
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
...
@@ -50,7 +51,7 @@ struct SameDimsElemwiseMul<platform::CUDADeviceContext, platform::float16> {
...
@@ -50,7 +51,7 @@ struct SameDimsElemwiseMul<platform::CUDADeviceContext, platform::float16> {
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
SameDimsElemwiseMulCUDAKernel
<<<
SameDimsElemwiseMulCUDAKernel
<<<
g
ir
d_size
,
block_size
,
0
,
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
x2
,
y2
,
z2
,
size
);
x2
,
y2
,
z2
,
size
);
}
}
...
@@ -82,10 +83,10 @@ elementwise_mul_grad(const framework::ExecutionContext& ctx,
...
@@ -82,10 +83,10 @@ elementwise_mul_grad(const framework::ExecutionContext& ctx,
framework
::
Tensor
*
dy
)
{
framework
::
Tensor
*
dy
)
{
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
g
ir
d_size
=
dim3
g
ri
d_size
=
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
SimpleElemwiseMulGradCUDAKernel
<
SimpleElemwiseMulGradCUDAKernel
<
T
><<<
g
ir
d_size
,
block_size
,
0
,
T
><<<
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
x
->
data
<
T
>
(),
y
->
data
<
T
>
(),
out
->
data
<
T
>
(),
dout
->
data
<
T
>
(),
size
,
x
->
data
<
T
>
(),
y
->
data
<
T
>
(),
out
->
data
<
T
>
(),
dout
->
data
<
T
>
(),
size
,
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
...
...
paddle/fluid/operators/elementwise/elementwise_sub_op.cu
浏览文件 @
9171f737
...
@@ -41,8 +41,9 @@ struct SameDimsElemwiseSub<platform::CUDADeviceContext, platform::float16> {
...
@@ -41,8 +41,9 @@ struct SameDimsElemwiseSub<platform::CUDADeviceContext, platform::float16> {
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
const
framework
::
Tensor
*
x
,
const
framework
::
Tensor
*
y
,
framework
::
Tensor
*
z
)
{
framework
::
Tensor
*
z
)
{
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
gird_size
=
dim3
(
dim3
grid_size
=
dim3
(((
size
+
1
)
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
(
size
/
2
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
const
half
*
x2
=
const
half
*
x2
=
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
x
->
data
<
platform
::
float16
>
());
...
@@ -50,7 +51,7 @@ struct SameDimsElemwiseSub<platform::CUDADeviceContext, platform::float16> {
...
@@ -50,7 +51,7 @@ struct SameDimsElemwiseSub<platform::CUDADeviceContext, platform::float16> {
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
reinterpret_cast
<
const
half
*>
(
y
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
half
*
z2
=
reinterpret_cast
<
half
*>
(
z
->
data
<
platform
::
float16
>
());
SameDimsElemwiseSubCUDAKernel
<<<
SameDimsElemwiseSubCUDAKernel
<<<
g
ir
d_size
,
block_size
,
0
,
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>().
stream
()
>>>
(
x2
,
y2
,
z2
,
size
);
x2
,
y2
,
z2
,
size
);
}
}
...
@@ -79,10 +80,10 @@ elementwise_sub_grad(const framework::ExecutionContext& ctx,
...
@@ -79,10 +80,10 @@ elementwise_sub_grad(const framework::ExecutionContext& ctx,
framework
::
Tensor
*
dy
)
{
framework
::
Tensor
*
dy
)
{
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
block_size
=
dim3
(
PADDLE_CUDA_THREAD_SIZE
,
1
);
auto
size
=
x
->
numel
();
auto
size
=
x
->
numel
();
dim3
g
ir
d_size
=
dim3
g
ri
d_size
=
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
dim3
((
size
+
PADDLE_CUDA_THREAD_SIZE
-
1
)
/
PADDLE_CUDA_THREAD_SIZE
,
1
);
SimpleElemwiseSubGradCUDAKernel
<
SimpleElemwiseSubGradCUDAKernel
<
T
><<<
g
ir
d_size
,
block_size
,
0
,
T
><<<
g
ri
d_size
,
block_size
,
0
,
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
ctx
.
template
device_context
<
plat
::
CUDADeviceContext
>().
stream
()
>>>
(
dout
->
data
<
T
>
(),
size
,
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dout
->
data
<
T
>
(),
size
,
dx
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()),
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
dy
->
mutable_data
<
T
>
(
ctx
.
GetPlace
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录