Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
18549417
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看板
未验证
提交
18549417
编写于
11月 11, 2022
作者:
zhouweiwei2014
提交者:
GitHub
11月 11, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Zero-Dim] fix batch_norm op infermeta bug (#47858)
上级
17dffd13
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
69 addition
and
54 deletion
+69
-54
paddle/fluid/operators/batch_norm_op.cc
paddle/fluid/operators/batch_norm_op.cc
+3
-0
paddle/fluid/operators/common_infer_shape_functions.cc
paddle/fluid/operators/common_infer_shape_functions.cc
+7
-6
paddle/fluid/operators/elementwise/elementwise_npu.h
paddle/fluid/operators/elementwise/elementwise_npu.h
+7
-6
paddle/phi/infermeta/multiary.cc
paddle/phi/infermeta/multiary.cc
+3
-0
paddle/phi/kernels/funcs/common_shape.h
paddle/phi/kernels/funcs/common_shape.h
+7
-6
paddle/phi/kernels/funcs/elementwise_base.h
paddle/phi/kernels/funcs/elementwise_base.h
+14
-12
paddle/phi/kernels/funcs/elementwise_grad_base.h
paddle/phi/kernels/funcs/elementwise_grad_base.h
+14
-12
paddle/phi/kernels/xpu/elementwise.h
paddle/phi/kernels/xpu/elementwise.h
+14
-12
未找到文件。
paddle/fluid/operators/batch_norm_op.cc
浏览文件 @
18549417
...
@@ -164,6 +164,9 @@ void BatchNormOp::InferShape(framework::InferShapeContext *ctx) const {
...
@@ -164,6 +164,9 @@ void BatchNormOp::InferShape(framework::InferShapeContext *ctx) const {
ctx
->
SetOutputDim
(
"SavedMean"
,
{
C
});
ctx
->
SetOutputDim
(
"SavedMean"
,
{
C
});
ctx
->
SetOutputDim
(
"SavedVariance"
,
{
C
});
ctx
->
SetOutputDim
(
"SavedVariance"
,
{
C
});
ctx
->
ShareLoD
(
"X"
,
"Y"
);
ctx
->
ShareLoD
(
"X"
,
"Y"
);
if
(
ctx
->
HasInput
(
"ReserveSpace"
))
{
ctx
->
SetOutputDim
(
"ReserveSpace"
,
{
-
1
});
}
}
}
framework
::
OpKernelType
BatchNormOp
::
GetExpectedKernelType
(
framework
::
OpKernelType
BatchNormOp
::
GetExpectedKernelType
(
...
...
paddle/fluid/operators/common_infer_shape_functions.cc
浏览文件 @
18549417
...
@@ -40,12 +40,13 @@ inline void GetBroadcastDimsArrays(const framework::DDim &x_dims,
...
@@ -40,12 +40,13 @@ inline void GetBroadcastDimsArrays(const framework::DDim &x_dims,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
platform
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
platform
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
if
(
x_dims
.
size
()
>
y_dims
.
size
())
{
if
(
x_dims
.
size
()
>
y_dims
.
size
())
{
std
::
fill
(
y_dims_array
,
y_dims_array
+
axis
,
1
);
std
::
fill
(
y_dims_array
,
y_dims_array
+
axis
,
1
);
if
(
axis
+
y_dims
.
size
()
<
max_dim
)
{
if
(
axis
+
y_dims
.
size
()
<
max_dim
)
{
...
...
paddle/fluid/operators/elementwise/elementwise_npu.h
浏览文件 @
18549417
...
@@ -123,12 +123,13 @@ void NpuElementWiseOpBroadcast(const platform::NPUDeviceContext& dev_ctx,
...
@@ -123,12 +123,13 @@ void NpuElementWiseOpBroadcast(const platform::NPUDeviceContext& dev_ctx,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
platform
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
platform
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
for
(
int
i
=
0
;
i
<
x_dims
.
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
x_dims
.
size
();
++
i
)
{
dst_dims_vec
[
i
+
x_axis
]
=
dst_dims_vec
[
i
+
x_axis
]
=
...
...
paddle/phi/infermeta/multiary.cc
浏览文件 @
18549417
...
@@ -640,6 +640,9 @@ void BatchNormInferMeta(const MetaTensor& x,
...
@@ -640,6 +640,9 @@ void BatchNormInferMeta(const MetaTensor& x,
if
(
saved_variance
)
{
if
(
saved_variance
)
{
saved_variance
->
set_dims
({
C
});
saved_variance
->
set_dims
({
C
});
}
}
if
(
reserve_space
)
{
reserve_space
->
set_dims
({
-
1
});
}
y
->
share_lod
(
x
);
y
->
share_lod
(
x
);
y
->
set_dtype
(
x
.
dtype
());
y
->
set_dtype
(
x
.
dtype
());
}
}
...
...
paddle/phi/kernels/funcs/common_shape.h
浏览文件 @
18549417
...
@@ -45,12 +45,13 @@ inline void GetBroadcastDimsArrays(const DDim &x_dims,
...
@@ -45,12 +45,13 @@ inline void GetBroadcastDimsArrays(const DDim &x_dims,
phi
::
errors
::
InvalidArgument
(
phi
::
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
phi
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
phi
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
if
(
x_dims
.
size
()
>
y_dims
.
size
())
{
if
(
x_dims
.
size
()
>
y_dims
.
size
())
{
std
::
fill
(
y_dims_array
,
y_dims_array
+
axis
,
1
);
std
::
fill
(
y_dims_array
,
y_dims_array
+
axis
,
1
);
if
(
axis
+
y_dims
.
size
()
<
max_dim
)
{
if
(
axis
+
y_dims
.
size
()
<
max_dim
)
{
...
...
paddle/phi/kernels/funcs/elementwise_base.h
浏览文件 @
18549417
...
@@ -326,12 +326,13 @@ void CommonElementwiseBroadcastForward(const CPUContext &dev_ctx,
...
@@ -326,12 +326,13 @@ void CommonElementwiseBroadcastForward(const CPUContext &dev_ctx,
phi
::
errors
::
InvalidArgument
(
phi
::
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
phi
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
phi
::
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
std
::
vector
<
int
>
x_dims_array
(
max_dim
);
std
::
vector
<
int
>
x_dims_array
(
max_dim
);
std
::
vector
<
int
>
y_dims_array
(
max_dim
);
std
::
vector
<
int
>
y_dims_array
(
max_dim
);
std
::
vector
<
int
>
out_dims_array
(
max_dim
);
std
::
vector
<
int
>
out_dims_array
(
max_dim
);
...
@@ -394,12 +395,13 @@ void ElementwiseCompute(const CPUContext &dev_ctx,
...
@@ -394,12 +395,13 @@ void ElementwiseCompute(const CPUContext &dev_ctx,
errors
::
InvalidArgument
(
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
int
pre
,
n
,
post
,
is_run_common_broadcast
,
axis_trim
=
0
;
int
pre
,
n
,
post
,
is_run_common_broadcast
,
axis_trim
=
0
;
if
(
is_xsize_larger
)
{
if
(
is_xsize_larger
)
{
...
...
paddle/phi/kernels/funcs/elementwise_grad_base.h
浏览文件 @
18549417
...
@@ -287,12 +287,13 @@ void ElemwiseGradComputeWithBroadcast(const CPUContext &ctx,
...
@@ -287,12 +287,13 @@ void ElemwiseGradComputeWithBroadcast(const CPUContext &ctx,
errors
::
InvalidArgument
(
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
int
pre
,
n
,
post
,
is_run_common_broadcast
,
axis_trim
=
0
;
int
pre
,
n
,
post
,
is_run_common_broadcast
,
axis_trim
=
0
;
if
(
is_xsize_larger
)
{
if
(
is_xsize_larger
)
{
...
@@ -1725,12 +1726,13 @@ void ElemwiseGradComputeWithBroadcast(const GPUContext &ctx,
...
@@ -1725,12 +1726,13 @@ void ElemwiseGradComputeWithBroadcast(const GPUContext &ctx,
errors
::
InvalidArgument
(
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
int
pre
,
n
,
post
,
is_run_common_broadcast
,
axis_trim
=
0
;
int
pre
,
n
,
post
,
is_run_common_broadcast
,
axis_trim
=
0
;
if
(
is_xsize_larger
)
{
if
(
is_xsize_larger
)
{
...
...
paddle/phi/kernels/xpu/elementwise.h
浏览文件 @
18549417
...
@@ -51,12 +51,13 @@ void XPUElementwise(const XPUContext& dev_ctx,
...
@@ -51,12 +51,13 @@ void XPUElementwise(const XPUContext& dev_ctx,
errors
::
InvalidArgument
(
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
std
::
vector
<
int
>
x_dims_vec
(
max_dim
,
1
);
std
::
vector
<
int
>
x_dims_vec
(
max_dim
,
1
);
std
::
vector
<
int
>
y_dims_vec
(
max_dim
,
1
);
std
::
vector
<
int
>
y_dims_vec
(
max_dim
,
1
);
if
(
x_dims
.
size
()
==
max_dim
)
{
if
(
x_dims
.
size
()
==
max_dim
)
{
...
@@ -121,12 +122,13 @@ void XPUElementwiseGrad(const XPUContext& dev_ctx,
...
@@ -121,12 +122,13 @@ void XPUElementwiseGrad(const XPUContext& dev_ctx,
errors
::
InvalidArgument
(
errors
::
InvalidArgument
(
"Axis should be great than or equal to 0, but received axis is %d."
,
"Axis should be great than or equal to 0, but received axis is %d."
,
axis
));
axis
));
PADDLE_ENFORCE_LE
(
axis
,
PADDLE_ENFORCE_LE
(
max_dim
,
axis
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than %d, but received axis is %d."
,
errors
::
InvalidArgument
(
max_dim
,
"Axis should be less than or equal to %d, but received axis is %d."
,
axis
));
max_dim
,
axis
));
std
::
vector
<
int
>
x_dims_vec
(
max_dim
,
1
);
std
::
vector
<
int
>
x_dims_vec
(
max_dim
,
1
);
std
::
vector
<
int
>
y_dims_vec
(
max_dim
,
1
);
std
::
vector
<
int
>
y_dims_vec
(
max_dim
,
1
);
if
(
x_dims
.
size
()
==
max_dim
)
{
if
(
x_dims
.
size
()
==
max_dim
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录