Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
4f834cb2
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看板
未验证
提交
4f834cb2
编写于
12月 01, 2022
作者:
Z
zhangyikun02
提交者:
GitHub
12月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change d2d copy to api copy in xpu kernel, test=kunlun (#48505)
上级
bc01d56e
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
24 addition
and
4 deletion
+24
-4
paddle/phi/kernels/xpu/elementwise_add_grad_kernel.cc
paddle/phi/kernels/xpu/elementwise_add_grad_kernel.cc
+10
-2
paddle/phi/kernels/xpu/warpctc_kernel.cc
paddle/phi/kernels/xpu/warpctc_kernel.cc
+9
-0
python/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py
...n/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py
+5
-2
未找到文件。
paddle/phi/kernels/xpu/elementwise_add_grad_kernel.cc
浏览文件 @
4f834cb2
...
@@ -45,7 +45,11 @@ void AddGradKernel(const Context& dev_ctx,
...
@@ -45,7 +45,11 @@ void AddGradKernel(const Context& dev_ctx,
T
*
dx_data
=
dev_ctx
.
template
Alloc
<
T
>(
dx
);
T
*
dx_data
=
dev_ctx
.
template
Alloc
<
T
>(
dx
);
if
(
dx
->
dims
()
==
dz_dims
)
{
if
(
dx
->
dims
()
==
dz_dims
)
{
if
(
dx_data
!=
dz_data
)
{
if
(
dx_data
!=
dz_data
)
{
Copy
(
dev_ctx
,
*
dz
,
dev_ctx
.
GetPlace
(),
false
,
dx
);
int
ret
=
xpu
::
copy
(
dev_ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
dz_data
),
reinterpret_cast
<
XPUType
*>
(
dx
->
data
<
T
>
()),
dx
->
numel
());
PADDLE_ENFORCE_XDNN_SUCCESS
(
ret
,
"copy"
);
}
}
}
else
{
}
else
{
// For inplace strategy, dx will be stored in addr of dz, which makes
// For inplace strategy, dx will be stored in addr of dz, which makes
...
@@ -73,7 +77,11 @@ void AddGradKernel(const Context& dev_ctx,
...
@@ -73,7 +77,11 @@ void AddGradKernel(const Context& dev_ctx,
T
*
dy_data
=
dy
->
mutable_data
<
T
>
(
dev_ctx
.
GetPlace
());
T
*
dy_data
=
dy
->
mutable_data
<
T
>
(
dev_ctx
.
GetPlace
());
if
(
dy
->
dims
()
==
dz_dims
)
{
if
(
dy
->
dims
()
==
dz_dims
)
{
if
(
dy_data
!=
dz_data
)
{
if
(
dy_data
!=
dz_data
)
{
Copy
(
dev_ctx
,
*
dz
,
dev_ctx
.
GetPlace
(),
false
,
dy
);
int
ret
=
xpu
::
copy
(
dev_ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
dz_data
),
reinterpret_cast
<
XPUType
*>
(
dy
->
data
<
T
>
()),
dy
->
numel
());
PADDLE_ENFORCE_XDNN_SUCCESS
(
ret
,
"copy"
);
}
}
}
else
{
}
else
{
std
::
vector
<
int
>
reduce_dims
=
std
::
vector
<
int
>
reduce_dims
=
...
...
paddle/phi/kernels/xpu/warpctc_kernel.cc
浏览文件 @
4f834cb2
...
@@ -68,6 +68,15 @@ void WarpctcKernel(const Context& dev_ctx,
...
@@ -68,6 +68,15 @@ void WarpctcKernel(const Context& dev_ctx,
"but received %d. "
,
"but received %d. "
,
sequence_width
));
sequence_width
));
int
lm_workspace
=
(
max_sequence_length
+
1
)
*
(
2
*
max_target_seq_length
+
sequence_width
+
1
)
*
sizeof
(
T
)
+
(
7
*
max_target_seq_length
+
3
)
*
sizeof
(
int
);
PADDLE_ENFORCE_LE
(
lm_workspace
,
6144
,
phi
::
errors
::
InvalidArgument
(
"Input size is too large for xpu in warpctc kernel"
));
loss
->
Resize
(
phi
::
make_ddim
({
num_sequences
,
1
}));
loss
->
Resize
(
phi
::
make_ddim
({
num_sequences
,
1
}));
dev_ctx
.
template
Alloc
<
T
>(
loss
);
dev_ctx
.
template
Alloc
<
T
>(
loss
);
...
...
python/paddle/fluid/tests/unittests/xpu/test_warpctc_op_xpu.py
浏览文件 @
4f834cb2
...
@@ -239,7 +239,6 @@ class XPUTestWarpCTCOp(XPUOpTestWrapper):
...
@@ -239,7 +239,6 @@ class XPUTestWarpCTCOp(XPUOpTestWrapper):
logits
=
np
.
random
.
uniform
(
logits
=
np
.
random
.
uniform
(
0.1
,
1.0
,
[
sum
(
self
.
logits_length
),
self
.
num_classes
]
0.1
,
1.0
,
[
sum
(
self
.
logits_length
),
self
.
num_classes
]
).
astype
(
self
.
dtype
)
).
astype
(
self
.
dtype
)
print
(
"logits.shape = "
,
logits
.
shape
)
softmax
=
np
.
apply_along_axis
(
stable_softmax
,
1
,
logits
)
softmax
=
np
.
apply_along_axis
(
stable_softmax
,
1
,
logits
)
# labels should not be blank
# labels should not be blank
labels
=
np
.
random
.
randint
(
labels
=
np
.
random
.
randint
(
...
@@ -416,7 +415,11 @@ class XPUTestWarpCTCOp(XPUOpTestWrapper):
...
@@ -416,7 +415,11 @@ class XPUTestWarpCTCOp(XPUOpTestWrapper):
labels
=
paddle
.
to_tensor
(
labels
)
labels
=
paddle
.
to_tensor
(
labels
)
paddle
.
nn
.
functional
.
ctc_loss
(
paddle
.
nn
.
functional
.
ctc_loss
(
log_probs
=
softmax
,
labels
=
labels
,
reduction
=
'none'
log_probs
=
softmax
,
labels
=
labels
,
input_lengths
=
None
,
label_lengths
=
None
,
reduction
=
'none'
,
)
)
paddle
.
disable_static
()
paddle
.
disable_static
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录