Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0e492e43
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
0e492e43
编写于
3月 15, 2023
作者:
R
ronnywang
提交者:
GitHub
3月 15, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] add int32,fp32 support for conv2d_transpose (#51677)
* [XPU] add int32,fp32 support for conv2d_transpose* * update
上级
09ae2852
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
82 addition
and
38 deletion
+82
-38
paddle/phi/kernels/xpu/bmm_grad_kernel.cc
paddle/phi/kernels/xpu/bmm_grad_kernel.cc
+7
-9
paddle/phi/kernels/xpu/bmm_kernel.cc
paddle/phi/kernels/xpu/bmm_kernel.cc
+7
-9
paddle/phi/kernels/xpu/conv_transpose_kernel.cc
paddle/phi/kernels/xpu/conv_transpose_kernel.cc
+68
-20
未找到文件。
paddle/phi/kernels/xpu/bmm_grad_kernel.cc
浏览文件 @
0e492e43
...
...
@@ -25,18 +25,16 @@ void MatMul(const Context& dev_ctx,
const
DenseTensor
&
b
,
bool
trans_b
,
DenseTensor
*
out
)
{
using
XPUT
=
typename
XPUTypeTrait
<
T
>::
Type
;
dev_ctx
.
template
Alloc
<
T
>(
out
);
xpu
::
Context
*
xpu_ctx
=
dev_ctx
.
x_context
();
if
(
std
::
is_same
<
phi
::
dtype
::
float16
,
T
>::
value
)
{
MatMulXPUFunction
<
T
,
int16_t
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
int
fccal_type
=
FCCalcType
<
XPUT
>
();
if
(
fccal_type
==
XPUFCCalcType
::
FC_INT32
)
{
MatMulXPUFunction
<
T
,
int32_t
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
}
else
if
(
fccal_type
==
XPUFCCalcType
::
FC_FLOAT
)
{
MatMulXPUFunction
<
T
,
float
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
}
else
{
if
(
std
::
getenv
(
"XPU_PADDLE_FC_INT32"
)
!=
nullptr
)
{
MatMulXPUFunction
<
T
,
int32_t
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
}
else
if
(
std
::
getenv
(
"XPU_PADDLE_FC_LOCAL_INT16"
)
!=
nullptr
)
{
MatMulXPUFunction
<
T
,
float
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
}
else
{
MatMulXPUFunction
<
T
,
int16_t
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
}
MatMulXPUFunction
<
T
,
int16_t
>
(
a
,
b
,
out
,
trans_a
,
trans_b
,
xpu_ctx
);
}
}
...
...
paddle/phi/kernels/xpu/bmm_kernel.cc
浏览文件 @
0e492e43
...
...
@@ -20,6 +20,7 @@ void BmmKernel(const Context& dev_ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
y
,
DenseTensor
*
out
)
{
using
XPUT
=
typename
XPUTypeTrait
<
T
>::
Type
;
dev_ctx
.
template
Alloc
<
T
>(
out
);
if
(
x
.
numel
()
==
0
||
y
.
numel
()
==
0
)
{
return
;
...
...
@@ -62,16 +63,13 @@ void BmmKernel(const Context& dev_ctx,
y_dims
[
1
]));
xpu
::
Context
*
xpu_ctx
=
dev_ctx
.
x_context
();
if
(
std
::
is_same
<
phi
::
dtype
::
float16
,
T
>::
value
)
{
MatMulXPUFunction
<
T
,
int16_t
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
int
fccal_type
=
FCCalcType
<
XPUT
>
();
if
(
fccal_type
==
XPUFCCalcType
::
FC_INT32
)
{
MatMulXPUFunction
<
T
,
int32_t
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
}
else
if
(
fccal_type
==
XPUFCCalcType
::
FC_FLOAT
)
{
MatMulXPUFunction
<
T
,
float
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
}
else
{
if
(
std
::
getenv
(
"XPU_PADDLE_FC_INT32"
)
!=
nullptr
)
{
MatMulXPUFunction
<
T
,
int32_t
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
}
else
if
(
std
::
getenv
(
"XPU_PADDLE_FC_LOCAL_INT16"
)
!=
nullptr
)
{
MatMulXPUFunction
<
T
,
float
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
}
else
{
MatMulXPUFunction
<
T
,
int16_t
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
}
MatMulXPUFunction
<
T
,
int16_t
>
(
x
,
y
,
out
,
trans_x
,
trans_y
,
xpu_ctx
);
}
}
}
// namespace phi
...
...
paddle/phi/kernels/xpu/conv_transpose_kernel.cc
浏览文件 @
0e492e43
...
...
@@ -17,6 +17,7 @@
#include "paddle/phi/backends/xpu/enforce_xpu.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/cpu/conv_util.h"
#include "paddle/phi/kernels/xpu/xpu_api_wrapper.h"
namespace
phi
{
...
...
@@ -48,6 +49,8 @@ void Conv2dTransposeKernel(const Context& ctx,
const
std
::
vector
<
int
>&
dilations
,
const
std
::
string
&
data_format
,
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.
...
...
@@ -76,26 +79,71 @@ void Conv2dTransposeKernel(const Context& ctx,
const
int
img_xh
=
static_cast
<
int
>
(
out
->
dims
()[
2
]);
const
int
img_xw
=
static_cast
<
int
>
(
out
->
dims
()[
3
]);
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
int16_t
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter_
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
img_xh
,
img_xw
,
img_xc
,
ksize
,
strides
,
paddings_
,
dilations_
,
groups
,
nullptr
,
nullptr
,
nullptr
,
true
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"conv2d_transpose_v2"
);
int
fccal_type
=
FCCalcType
<
XPUT
>
();
if
(
fccal_type
==
XPUFCCalcType
::
FC_INT32
)
{
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
int32_t
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter_
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
img_xh
,
img_xw
,
img_xc
,
ksize
,
strides
,
paddings_
,
dilations_
,
groups
,
nullptr
,
nullptr
,
nullptr
,
true
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"conv2d_transpose_v2"
);
}
else
if
(
fccal_type
==
XPUFCCalcType
::
FC_FLOAT
)
{
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
float
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter_
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
img_xh
,
img_xw
,
img_xc
,
ksize
,
strides
,
paddings_
,
dilations_
,
groups
,
nullptr
,
nullptr
,
nullptr
,
true
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"conv2d_transpose_v2"
);
}
else
{
int
r
=
xpu
::
conv2d_transpose_v2
<
float
,
float
,
float
,
int16_t
>
(
ctx
.
x_context
(),
x
.
data
<
float
>
(),
filter_
.
data
<
float
>
(),
out
->
data
<
float
>
(),
batch_size
,
img_yc
,
img_xh
,
img_xw
,
img_xc
,
ksize
,
strides
,
paddings_
,
dilations_
,
groups
,
nullptr
,
nullptr
,
nullptr
,
true
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"conv2d_transpose_v2"
);
}
}
}
// namespace phi
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录