Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
8305ba37
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看板
未验证
提交
8305ba37
编写于
9月 03, 2021
作者:
T
TTerror
提交者:
GitHub
9月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bn_infer and optimize momentum for kunlun (#35250)
上级
8ba58eb0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
24 addition
and
21 deletion
+24
-21
cmake/external/xpu.cmake
cmake/external/xpu.cmake
+1
-1
paddle/fluid/operators/batch_norm_op_xpu.cc
paddle/fluid/operators/batch_norm_op_xpu.cc
+15
-16
paddle/fluid/operators/optimizers/momentum_op_xpu.cc
paddle/fluid/operators/optimizers/momentum_op_xpu.cc
+4
-4
paddle/fluid/platform/xpu/xpu2_op_list.h
paddle/fluid/platform/xpu/xpu2_op_list.h
+4
-0
未找到文件。
cmake/external/xpu.cmake
浏览文件 @
8305ba37
...
...
@@ -35,7 +35,7 @@ ELSE ()
ENDIF
()
SET
(
XPU_BASE_URL_WITHOUT_DATE
"https://baidu-kunlun-product.cdn.bcebos.com/KL-SDK/klsdk-dev"
)
SET
(
XPU_BASE_URL
"
${
XPU_BASE_URL_WITHOUT_DATE
}
/202108
26
"
)
SET
(
XPU_BASE_URL
"
${
XPU_BASE_URL_WITHOUT_DATE
}
/202108
30
"
)
SET
(
XPU_XRE_URL
"
${
XPU_BASE_URL
}
/
${
XPU_XRE_DIR_NAME
}
.tar.gz"
CACHE STRING
""
FORCE
)
SET
(
XPU_XDNN_URL
"
${
XPU_BASE_URL
}
/
${
XPU_XDNN_DIR_NAME
}
.tar.gz"
CACHE STRING
""
FORCE
)
SET
(
XPU_XCCL_URL
"
${
XPU_BASE_URL_WITHOUT_DATE
}
/20210623/
${
XPU_XCCL_DIR_NAME
}
.tar.gz"
CACHE STRING
""
FORCE
)
...
...
paddle/fluid/operators/batch_norm_op_xpu.cc
浏览文件 @
8305ba37
...
...
@@ -76,26 +76,25 @@ class BatchNormXPUKernel : public framework::OpKernel<T> {
W
,
epsilon
,
momentum
,
scale_data
,
bias_data
,
saved_mean_data
,
saved_variance_data
,
mean_out_data
,
variance_out_data
,
true
);
PADDLE_ENFORCE_EQ
(
r
,
XPU_SUCCESS
,
platform
::
errors
::
External
(
"XPU API(batch_norm_train_forward) return "
"wrong value[%d], please check whether "
"Baidu Kunlun Card is properly installed."
,
r
));
PADDLE_ENFORCE_EQ
(
r
,
xpu
::
Error_t
::
SUCCESS
,
platform
::
errors
::
External
(
"The batch_norm XPU API return wrong value[%d %s]"
,
r
,
XPUAPIErrorMsg
[
r
]));
}
else
{
const
auto
*
mean
=
ctx
.
Input
<
Tensor
>
(
"Mean"
);
const
auto
*
variance
=
ctx
.
Input
<
Tensor
>
(
"Variance"
);
const
auto
*
mean_data
=
mean
->
data
<
T
>
();
const
auto
*
variance_data
=
variance
->
data
<
T
>
();
int
r
=
xpu
::
batch_norm_infer_forward
(
dev_ctx
.
x_context
(),
epsilon
,
N
,
C
,
H
,
W
,
x_data
,
y_data
,
scale_data
,
bias_data
,
mean_data
,
variance_data
);
const
auto
*
mean_data
=
mean
->
data
<
float
>
();
const
auto
*
variance_data
=
variance
->
data
<
float
>
();
const
auto
*
x_data
=
x
->
data
<
float
>
();
auto
*
y_data
=
y
->
mutable_data
<
float
>
(
ctx
.
GetPlace
());
int
r
=
xpu
::
batch_norm_infer
(
dev_ctx
.
x_context
(),
x_data
,
y_data
,
N
,
C
,
H
,
W
,
epsilon
,
scale_data
,
bias_data
,
mean_data
,
variance_data
,
true
);
PADDLE_ENFORCE_EQ
(
r
,
XPU_SUCCESS
,
platform
::
errors
::
External
(
"XPU API(batch_norm_infer_forward) return "
"wrong value[%d], please check whether "
"Baidu Kunlun Card is properly installed."
,
r
));
r
,
xpu
::
Error_t
::
SUCCESS
,
platform
::
errors
::
External
(
"The batch_norm_infer XPU API return wrong value[%d %s]"
,
r
,
XPUAPIErrorMsg
[
r
]));
}
}
};
...
...
paddle/fluid/operators/optimizers/momentum_op_xpu.cc
浏览文件 @
8305ba37
...
...
@@ -44,10 +44,10 @@ class MomentumOpXPUKernel : public framework::OpKernel<T> {
auto
grad
=
ctx
.
Input
<
framework
::
Tensor
>
(
"Grad"
);
auto
&
dev_ctx
=
ctx
.
template
device_context
<
DeviceContext
>();
int
r
=
xpu
::
momentum
(
dev_ctx
.
x_context
(),
param
->
data
<
float
>
(),
velocity
->
data
<
float
>
(),
grad
->
data
<
float
>
(),
lr
,
use_nesterov
,
mu
,
param_out
->
numel
(),
param_out
->
data
<
float
>
(),
velocity_out
->
data
<
float
>
()
);
int
r
=
xpu
::
momentum
(
dev_ctx
.
x_context
(),
param
->
data
<
float
>
(),
velocity
->
data
<
float
>
(),
grad
->
data
<
float
>
(),
param_out
->
data
<
float
>
(),
velocity_out
->
data
<
float
>
(),
param_out
->
numel
(),
lr
,
use_nesterov
,
mu
);
if
(
r
==
xpu
::
Error_t
::
INVALID_PARAM
)
{
PADDLE_ENFORCE_EQ
(
r
,
xpu
::
Error_t
::
SUCCESS
,
...
...
paddle/fluid/platform/xpu/xpu2_op_list.h
浏览文件 @
8305ba37
...
...
@@ -75,6 +75,10 @@ XPUOpMap& get_kl2_ops() {
{
"elementwise_min_grad"
,
XPUKernelSet
({
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
()),
pOpKernelType
(
vartype
::
FP16
,
XPUPlace
())})},
{
"momentum"
,
XPUKernelSet
({
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
())})},
{
"batch_norm"
,
XPUKernelSet
({
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
())})},
{
"batch_norm_grad"
,
XPUKernelSet
({
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
())})},
// AddMore
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录