Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7e4290c5
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
7e4290c5
编写于
7月 14, 2023
作者:
H
hong19860320
提交者:
GitHub
7月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] Fix yolo_box to support multi-stream based inference (#55310)
上级
76b77d81
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
36 deletion
+24
-36
paddle/phi/kernels/fusion/xpu/conv_transpose_xpu_kernel.cc
paddle/phi/kernels/fusion/xpu/conv_transpose_xpu_kernel.cc
+2
-6
paddle/phi/kernels/fusion/xpu/yolo_box_xpu_kernel.cc
paddle/phi/kernels/fusion/xpu/yolo_box_xpu_kernel.cc
+17
-20
paddle/phi/kernels/xpu/conv_transpose_kernel.cc
paddle/phi/kernels/xpu/conv_transpose_kernel.cc
+5
-10
未找到文件。
paddle/phi/kernels/fusion/xpu/conv_transpose_xpu_kernel.cc
浏览文件 @
7e4290c5
...
...
@@ -41,17 +41,13 @@ void Conv2dTransposeXPUKernel(const Context& ctx,
DenseTensor
*
out_max
)
{
using
XPUT
=
typename
XPUTypeTrait
<
T
>::
Type
;
// The filter will be reshaped in the calculations,
// so here use an assignment operation,
// that avoids modifying the variable in the Scope.
DenseTensor
filter_
=
filter
;
ctx
.
template
Alloc
<
T
>(
out
);
ctx
.
template
Alloc
<
float
>(
out_max
);
bool
is_nchw
;
is_nchw
=
(
data_format
==
"NHWC"
)
?
false
:
true
;
DDim
in_data_dims
=
slice_ddim
(
x
.
dims
(),
2
,
x
.
dims
().
size
());
// hw
DDim
filter_data_dims
=
slice_ddim
(
filter
_
.
dims
(),
2
,
filter_
.
dims
().
size
());
DDim
filter_data_dims
=
slice_ddim
(
filter
.
dims
(),
2
,
filter
.
dims
().
size
());
std
::
vector
<
int
>
ksize
=
vectorize
<
int
>
(
filter_data_dims
);
std
::
vector
<
int
>
paddings_
=
paddings
;
std
::
vector
<
int
>
dilations_
=
dilations
;
...
...
@@ -78,7 +74,7 @@ void Conv2dTransposeXPUKernel(const Context& ctx,
int
r
=
xpu
::
conv2d_transpose_fusion_v2
<
XPUT
,
int16_t
,
XPUT
,
int16_t
>
(
ctx
.
x_context
(),
reinterpret_cast
<
const
XPUT
*>
(
x
.
data
<
T
>
()),
filter
_
.
data
<
int16_t
>
(),
filter
.
data
<
int16_t
>
(),
reinterpret_cast
<
XPUT
*>
(
out
->
data
<
T
>
()),
batch_size
,
img_yc
,
...
...
paddle/phi/kernels/fusion/xpu/yolo_box_xpu_kernel.cc
浏览文件 @
7e4290c5
...
...
@@ -38,36 +38,33 @@ void YoloBoxXPUKernel(const Context& ctx,
const
float
*
stride_data
;
const
float
*
anchor_grid_data
;
// fix precision of fp16 model
xpu
::
ctx_guard
RAII_GUARD
(
ctx
.
x_context
());
if
(
std
::
is_same
<
T
,
phi
::
dtype
::
float16
>::
value
)
{
DenseTensor
grid_data_fp32_t
;
DenseTensor
stride_data_fp32_t
;
DenseTensor
anchor_grid_data_fp32_t
;
ctx
.
template
Alloc
<
float
>(
&
grid_data_fp32_t
,
grid
.
numel
()
*
sizeof
(
float
));
int
r1
=
xpu
::
cast
<
XPUType
,
float
>
(
float
*
grid_data_temp
=
RAII_GUARD
.
alloc_l3_or_gm
<
float
>
(
grid
.
numel
());
int
r
=
xpu
::
cast
<
XPUType
,
float
>
(
ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
grid
.
data
<
T
>
()),
grid_data_
fp32_t
.
data
<
float
>
()
,
grid_data_
temp
,
grid
.
numel
());
PADDLE_ENFORCE_XDNN_SUCCESS
(
r1
,
"cast"
);
ctx
.
template
Alloc
<
float
>(
&
stride_data_fp32_t
,
stride
.
numel
()
*
sizeof
(
float
));
int
r2
=
xpu
::
cast
<
XPUType
,
float
>
(
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"cast"
);
float
*
stride_data_temp
=
RAII_GUARD
.
alloc_l3_or_gm
<
float
>
(
stride
.
numel
());
r
=
xpu
::
cast
<
XPUType
,
float
>
(
ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
stride
.
data
<
T
>
()),
stride_data_
fp32_t
.
data
<
float
>
()
,
stride_data_
temp
,
stride
.
numel
());
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
2
,
"cast"
);
ctx
.
template
Alloc
<
float
>(
&
anchor_grid_data_fp32_t
,
anchor_grid
.
numel
()
*
sizeof
(
float
));
int
r3
=
xpu
::
cast
<
XPUType
,
float
>
(
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"cast"
);
float
*
anchor_grid_data_temp
=
RAII_GUARD
.
alloc_l3_or_gm
<
float
>
(
anchor_grid
.
numel
(
));
r
=
xpu
::
cast
<
XPUType
,
float
>
(
ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
anchor_grid
.
data
<
T
>
()),
anchor_grid_data_
fp32_t
.
data
<
float
>
()
,
anchor_grid_data_
temp
,
anchor_grid
.
numel
());
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
3
,
"cast"
);
grid_data
=
grid_data_
fp32_t
.
data
<
float
>
()
;
stride_data
=
stride_data_
fp32_t
.
data
<
float
>
()
;
anchor_grid_data
=
anchor_grid_data_
fp32_t
.
data
<
float
>
()
;
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"cast"
);
grid_data
=
grid_data_
temp
;
stride_data
=
stride_data_
temp
;
anchor_grid_data
=
anchor_grid_data_
temp
;
}
else
{
grid_data
=
grid
.
data
<
float
>
();
stride_data
=
stride
.
data
<
float
>
();
...
...
paddle/phi/kernels/xpu/conv_transpose_kernel.cc
浏览文件 @
7e4290c5
...
...
@@ -53,11 +53,6 @@ void Conv2dTransposeKernel(const Context& ctx,
DenseTensor
*
out
)
{
using
XPUT
=
typename
XPUTypeTrait
<
T
>::
Type
;
// The filter will be reshaped in the calculations,
// so here use an assignment operation,
// that avoids modifying the variable in the Scope.
DenseTensor
filter_
=
filter
;
ctx
.
template
Alloc
<
T
>(
out
);
PADDLE_ENFORCE_EQ
(
...
...
@@ -67,7 +62,7 @@ void Conv2dTransposeKernel(const Context& ctx,
(
"XPU do support data_format is NCHW in conv_transpose op."
)));
DDim
in_data_dims
=
slice_ddim
(
x
.
dims
(),
2
,
x
.
dims
().
size
());
DDim
filter_data_dims
=
slice_ddim
(
filter
_
.
dims
(),
2
,
filter_
.
dims
().
size
());
DDim
filter_data_dims
=
slice_ddim
(
filter
.
dims
(),
2
,
filter
.
dims
().
size
());
std
::
vector
<
int
>
ksize
=
vectorize
<
int
>
(
filter_data_dims
);
std
::
vector
<
int
>
paddings_
=
paddings
;
...
...
@@ -86,7 +81,7 @@ void Conv2dTransposeKernel(const Context& ctx,
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
int32_t
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter
_
.
data
<
float
>
(),
filter
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
...
...
@@ -107,7 +102,7 @@ void Conv2dTransposeKernel(const Context& ctx,
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
float
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter
_
.
data
<
float
>
(),
filter
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
...
...
@@ -132,7 +127,7 @@ void Conv2dTransposeKernel(const Context& ctx,
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
int32_t
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter
_
.
data
<
float
>
(),
filter
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
...
...
@@ -157,7 +152,7 @@ void Conv2dTransposeKernel(const Context& ctx,
int
r
=
xpu
::
conv2d_transpose
<
float
,
float
,
float
,
int_with_ll_t
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter
_
.
data
<
float
>
(),
filter
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录