Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
b7560a59
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看板
未验证
提交
b7560a59
编写于
2月 03, 2021
作者:
W
wawltor
提交者:
GitHub
2月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the broadcast for the large second input (#30818)
fix the broadcast for the large second input
上级
6e1e036a
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
12 addition
and
4 deletion
+12
-4
paddle/fluid/operators/elementwise/elementwise_op_function.h
paddle/fluid/operators/elementwise/elementwise_op_function.h
+2
-4
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
...n/paddle/fluid/tests/unittests/test_elementwise_add_op.py
+10
-0
未找到文件。
paddle/fluid/operators/elementwise/elementwise_op_function.h
浏览文件 @
b7560a59
...
@@ -708,10 +708,10 @@ static __global__ void FastCommonGradBroadcastAllCUDAKernel(
...
@@ -708,10 +708,10 @@ static __global__ void FastCommonGradBroadcastAllCUDAKernel(
int
x_offset
=
b_i
*
post
+
b_j
;
int
x_offset
=
b_i
*
post
+
b_j
;
if
(
dy
)
{
if
(
dy
)
{
dy
[
y_offset
]
=
dy
[
y_offset
]
=
dy_op
(
x
[
x_offset
],
y
[
y_offset
],
out
[
x_offset
],
dout
[
x
_offset
]);
dy_op
(
x
[
x_offset
],
y
[
y_offset
],
out
[
y_offset
],
dout
[
y
_offset
]);
}
}
if
(
dx
)
{
if
(
dx
)
{
val
+=
dx_op
(
x
[
x_offset
],
y
[
y_offset
],
out
[
x_offset
],
dout
[
x
_offset
]);
val
+=
dx_op
(
x
[
x_offset
],
y
[
y_offset
],
out
[
y_offset
],
dout
[
y
_offset
]);
}
}
}
}
if
(
dx
)
{
if
(
dx
)
{
...
@@ -1674,7 +1674,6 @@ void CommonElementwiseBroadcastBackward(
...
@@ -1674,7 +1674,6 @@ void CommonElementwiseBroadcastBackward(
GetBroadcastDimsArrays
(
x_dims
,
y_dims
,
x_dims_array
.
data
(),
GetBroadcastDimsArrays
(
x_dims
,
y_dims
,
x_dims_array
.
data
(),
y_dims_array
.
data
(),
out_dims_array
.
data
(),
max_dim
,
y_dims_array
.
data
(),
out_dims_array
.
data
(),
max_dim
,
axis
);
axis
);
// for inplace strategy. memset will make dx and dout clear and get wrong
// for inplace strategy. memset will make dx and dout clear and get wrong
// result.
// result.
if
(
dx
&&
dx
->
IsSharedBufferWith
(
dout
))
{
if
(
dx
&&
dx
->
IsSharedBufferWith
(
dout
))
{
...
@@ -1762,7 +1761,6 @@ void ElemwiseGradComputeWithBroadcast(
...
@@ -1762,7 +1761,6 @@ void ElemwiseGradComputeWithBroadcast(
get_mid_dims
(
y_dims
,
x_dims_trimed
,
axis_trim
,
&
pre
,
&
n
,
&
post
,
get_mid_dims
(
y_dims
,
x_dims_trimed
,
axis_trim
,
&
pre
,
&
n
,
&
post
,
&
is_run_common_broadcast
);
&
is_run_common_broadcast
);
}
}
// special case for common backward implementation.
// special case for common backward implementation.
if
(
is_run_common_broadcast
)
{
if
(
is_run_common_broadcast
)
{
CommonElementwiseBroadcastBackward
<
DeviceContext
,
T
,
DX_OP
,
DY_OP
>
(
CommonElementwiseBroadcastBackward
<
DeviceContext
,
T
,
DX_OP
,
DY_OP
>
(
...
...
python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
浏览文件 @
b7560a59
...
@@ -381,6 +381,16 @@ class TestElementwiseAddOp_xsize_lessthan_ysize_add(TestElementwiseAddOp):
...
@@ -381,6 +381,16 @@ class TestElementwiseAddOp_xsize_lessthan_ysize_add(TestElementwiseAddOp):
self
.
axis
=
2
self
.
axis
=
2
class
TestElementwiseAddOp_same_shape_ysize_large
(
TestElementwiseAddOp
):
def
init_input_output
(
self
):
self
.
x
=
np
.
random
.
rand
(
10
,
1
,
12
).
astype
(
self
.
dtype
)
self
.
y
=
np
.
random
.
rand
(
10
,
3
,
12
).
astype
(
self
.
dtype
)
self
.
out
=
self
.
x
+
self
.
y
def
init_axis
(
self
):
self
.
axis
=
0
class
TestElementwiseAddOpError
(
unittest
.
TestCase
):
class
TestElementwiseAddOpError
(
unittest
.
TestCase
):
def
test_errors
(
self
):
def
test_errors
(
self
):
with
program_guard
(
Program
(),
Program
()):
with
program_guard
(
Program
(),
Program
()):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录