Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
18e0e01d
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看板
未验证
提交
18e0e01d
编写于
2月 09, 2023
作者:
L
Leo Guo
提交者:
GitHub
2月 09, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify full kernel for xpu. test=kunlun (#50209)
上级
350cd82a
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
37 addition
and
20 deletion
+37
-20
paddle/phi/backends/xpu/xpu2_op_list.cc
paddle/phi/backends/xpu/xpu2_op_list.cc
+1
-4
paddle/phi/kernels/selected_rows/full_kernel.cc
paddle/phi/kernels/selected_rows/full_kernel.cc
+14
-0
paddle/phi/kernels/xpu/full_kernel.cc
paddle/phi/kernels/xpu/full_kernel.cc
+22
-16
未找到文件。
paddle/phi/backends/xpu/xpu2_op_list.cc
浏览文件 @
18e0e01d
...
@@ -248,11 +248,8 @@ XPUOpMap& get_kl2_ops() {
...
@@ -248,11 +248,8 @@ XPUOpMap& get_kl2_ops() {
phi
::
DataType
::
INT16
,
phi
::
DataType
::
INT16
,
phi
::
DataType
::
UINT8
,
phi
::
DataType
::
UINT8
,
phi
::
DataType
::
BOOL
,
phi
::
DataType
::
BOOL
,
phi
::
DataType
::
FLOAT64
,
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
,
phi
::
DataType
::
FLOAT16
})},
phi
::
DataType
::
COMPLEX64
,
phi
::
DataType
::
COMPLEX128
})},
{
"flatten2_grad"
,
{
"flatten2_grad"
,
XPUKernelSet
({
phi
::
DataType
::
INT64
,
XPUKernelSet
({
phi
::
DataType
::
INT64
,
phi
::
DataType
::
INT32
,
phi
::
DataType
::
INT32
,
...
...
paddle/phi/kernels/selected_rows/full_kernel.cc
浏览文件 @
18e0e01d
...
@@ -70,3 +70,17 @@ PD_REGISTER_KERNEL(full_sr,
...
@@ -70,3 +70,17 @@ PD_REGISTER_KERNEL(full_sr,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
)
{}
phi
::
dtype
::
complex
<
double
>
)
{}
#endif
#endif
#if defined(PADDLE_WITH_XPU) && !defined(PADDLE_WITH_XPU_KP)
PD_REGISTER_KERNEL
(
full_sr
,
XPU
,
ALL_LAYOUT
,
phi
::
sr
::
FullKernel
,
float
,
uint8_t
,
int16_t
,
int
,
int64_t
,
bool
,
phi
::
dtype
::
float16
)
{}
#endif
paddle/phi/kernels/xpu/full_kernel.cc
浏览文件 @
18e0e01d
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include "paddle/phi/kernels/full_kernel.h"
#include "paddle/phi/kernels/full_kernel.h"
#include "paddle/phi/backends/xpu/enforce_xpu.h"
#include "paddle/phi/backends/xpu/xpu_context.h"
#include "paddle/phi/backends/xpu/xpu_context.h"
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/bfloat16.h"
#include "paddle/phi/common/complex.h"
#include "paddle/phi/common/complex.h"
...
@@ -59,8 +60,19 @@ void FullKernel(const Context& dev_ctx,
...
@@ -59,8 +60,19 @@ void FullKernel(const Context& dev_ctx,
const
Scalar
&
val
,
const
Scalar
&
val
,
DataType
dtype
,
DataType
dtype
,
DenseTensor
*
out
)
{
DenseTensor
*
out
)
{
using
XPUInTDType
=
typename
XPUTypeTrait
<
T
>::
Type
;
out
->
Resize
(
phi
::
make_ddim
(
shape
.
GetData
()));
out
->
Resize
(
phi
::
make_ddim
(
shape
.
GetData
()));
FullValueXPU
<
T
>
(
dev_ctx
,
out
,
val
.
to
<
T
>
());
int
numel
=
out
->
numel
();
dev_ctx
.
template
Alloc
<
T
>(
out
);
auto
value
=
val
.
to
<
double
>
();
auto
out_data
=
reinterpret_cast
<
XPUInTDType
*>
(
out
->
data
<
T
>
());
if
(
numel
>
0
)
{
int
r
=
xpu
::
constant
(
dev_ctx
.
x_context
(),
out_data
,
out
->
numel
(),
static_cast
<
XPUInTDType
>
(
value
));
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"constant"
);
}
}
}
template
<
typename
T
,
typename
Context
>
template
<
typename
T
,
typename
Context
>
...
@@ -103,16 +115,11 @@ void FullLikeKernel(const Context& dev_ctx,
...
@@ -103,16 +115,11 @@ void FullLikeKernel(const Context& dev_ctx,
phi
::
errors
::
InvalidArgument
(
"The filled value is Inf."
));
phi
::
errors
::
InvalidArgument
(
"The filled value is Inf."
));
auto
out_data
=
reinterpret_cast
<
XPUInTDType
*>
(
out
->
data
<
T
>
());
auto
out_data
=
reinterpret_cast
<
XPUInTDType
*>
(
out
->
data
<
T
>
());
int
r
et
=
xpu
::
constant
(
dev_ctx
.
x_context
(),
int
r
=
xpu
::
constant
(
dev_ctx
.
x_context
(),
out_data
,
out_data
,
out
->
numel
(),
out
->
numel
(),
static_cast
<
XPUInTDType
>
(
value
));
static_cast
<
XPUInTDType
>
(
value
));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"constant"
);
ret
,
XPU_SUCCESS
,
phi
::
errors
::
External
(
"XPU CONSTANT API return wrong value[%d %s]."
,
ret
,
XPUAPIErrorMsg
[
ret
]));
}
}
}
// namespace phi
}
// namespace phi
...
@@ -122,24 +129,23 @@ PD_REGISTER_KERNEL(full,
...
@@ -122,24 +129,23 @@ PD_REGISTER_KERNEL(full,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
FullKernel
,
phi
::
FullKernel
,
float
,
float
,
double
,
uint8_t
,
uint8_t
,
int16_t
,
int16_t
,
int
,
int
,
int64_t
,
int64_t
,
bool
,
bool
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
float16
)
{}
phi
::
dtype
::
bfloat16
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
)
{}
PD_REGISTER_KERNEL
(
full_like
,
PD_REGISTER_KERNEL
(
full_like
,
XPU
,
XPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
FullLikeKernel
,
phi
::
FullLikeKernel
,
float
,
float
,
uint8_t
,
int16_t
,
int
,
int
,
int64_t
,
int64_t
,
bool
,
phi
::
dtype
::
float16
)
{
phi
::
dtype
::
float16
)
{
kernel
->
InputAt
(
0
).
SetBackend
(
phi
::
Backend
::
ALL_BACKEND
);
kernel
->
InputAt
(
0
).
SetBackend
(
phi
::
Backend
::
ALL_BACKEND
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录