Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
307128d1
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 2 年 前同步成功
通知
2325
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
307128d1
编写于
8月 10, 2023
作者:
J
jiangfan06
提交者:
GitHub
8月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[XPU] Add gather_nd fp16 and add check_dtype_op_blacklist (#55860)
上级
b546b923
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
31 addition
and
18 deletion
+31
-18
paddle/fluid/framework/ir/auto_mixed_precision_pass.cc
paddle/fluid/framework/ir/auto_mixed_precision_pass.cc
+4
-1
paddle/phi/backends/xpu/xpu2_op_list.cc
paddle/phi/backends/xpu/xpu2_op_list.cc
+2
-1
paddle/phi/kernels/xpu/gather_nd_kernel.cc
paddle/phi/kernels/xpu/gather_nd_kernel.cc
+25
-16
未找到文件。
paddle/fluid/framework/ir/auto_mixed_precision_pass.cc
浏览文件 @
307128d1
...
@@ -406,7 +406,10 @@ void AutoMixedPrecisionPass::GetOpPrecision() const {
...
@@ -406,7 +406,10 @@ void AutoMixedPrecisionPass::GetOpPrecision() const {
support_low_precision
=
OpSupportPrecision
(
support_low_precision
=
OpSupportPrecision
(
GetOpOriginalType
(
op_type
),
backend_
,
low_precision_
,
black_list_
);
GetOpOriginalType
(
op_type
),
backend_
,
low_precision_
,
black_list_
);
if
(
op_node
->
Op
()
->
HasAttr
(
"dtype"
))
{
std
::
unordered_set
<
std
::
string
>
check_dtype_op_blacklist
(
{
"arg_max"
,
"arg_min"
});
if
(
op_node
->
Op
()
->
HasAttr
(
"dtype"
)
&&
!
check_dtype_op_blacklist
.
count
(
GetOpOriginalType
(
op_type
)))
{
auto
dtype
=
op_node
->
Op
()
->
GetAttrIfExists
<
int
>
(
"dtype"
);
auto
dtype
=
op_node
->
Op
()
->
GetAttrIfExists
<
int
>
(
"dtype"
);
support_low_precision
=
support_low_precision
=
support_low_precision
&&
support_low_precision
&&
...
...
paddle/phi/backends/xpu/xpu2_op_list.cc
浏览文件 @
307128d1
...
@@ -397,7 +397,8 @@ XPUOpMap& get_kl2_ops() {
...
@@ -397,7 +397,8 @@ XPUOpMap& get_kl2_ops() {
{
"gather_nd"
,
{
"gather_nd"
,
XPUKernelSet
({
phi
::
DataType
::
INT32
,
XPUKernelSet
({
phi
::
DataType
::
INT32
,
phi
::
DataType
::
INT64
,
phi
::
DataType
::
INT64
,
phi
::
DataType
::
FLOAT32
})},
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
})},
{
"gather"
,
{
"gather"
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
XPUKernelSet
({
phi
::
DataType
::
FLOAT32
,
phi
::
DataType
::
FLOAT16
,
phi
::
DataType
::
FLOAT16
,
...
...
paddle/phi/kernels/xpu/gather_nd_kernel.cc
浏览文件 @
307128d1
...
@@ -24,6 +24,7 @@ void GatherNdKernel(const Context &ctx,
...
@@ -24,6 +24,7 @@ void GatherNdKernel(const Context &ctx,
const
DenseTensor
&
x
,
const
DenseTensor
&
x
,
const
DenseTensor
&
index
,
const
DenseTensor
&
index
,
DenseTensor
*
out
)
{
DenseTensor
*
out
)
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
ctx
.
template
Alloc
<
T
>(
out
);
ctx
.
template
Alloc
<
T
>(
out
);
if
(
x
.
numel
()
==
0
)
{
if
(
x
.
numel
()
==
0
)
{
...
@@ -57,8 +58,8 @@ void GatherNdKernel(const Context &ctx,
...
@@ -57,8 +58,8 @@ void GatherNdKernel(const Context &ctx,
// int broadcast(Context* ctx, const T* x, T* y, const std::vector<int>&
// int broadcast(Context* ctx, const T* x, T* y, const std::vector<int>&
// xshape, const std::vector<int>& yshape)
// xshape, const std::vector<int>& yshape)
int
r
=
xpu
::
broadcast
(
ctx
.
x_context
(),
int
r
=
xpu
::
broadcast
(
ctx
.
x_context
(),
x
.
data
<
T
>
(
),
reinterpret_cast
<
const
XPUType
*>
(
x
.
data
<
T
>
()
),
out
->
data
<
T
>
(
),
reinterpret_cast
<
XPUType
*>
(
out
->
data
<
T
>
()
),
{
1
,
x_numel
},
{
1
,
x_numel
},
{
remain_numel
,
x_numel
});
{
remain_numel
,
x_numel
});
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"broadcast"
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"broadcast"
);
...
@@ -87,17 +88,19 @@ void GatherNdKernel(const Context &ctx,
...
@@ -87,17 +88,19 @@ void GatherNdKernel(const Context &ctx,
int
ret
=
XPU_SUCCESS
;
int
ret
=
XPU_SUCCESS
;
if
(
index_type
==
DataType
::
INT32
)
{
if
(
index_type
==
DataType
::
INT32
)
{
ret
=
xpu
::
gather_nd
<
T
,
int
>
(
ctx
.
x_context
(),
ret
=
xpu
::
gather_nd
<
XPUType
,
int
>
(
x
.
data
<
T
>
(),
ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
x
.
data
<
T
>
()),
index
.
data
<
int
>
(),
index
.
data
<
int
>
(),
out
->
data
<
T
>
(
),
reinterpret_cast
<
XPUType
*>
(
out
->
data
<
T
>
()
),
x_vec
,
x_vec
,
index_shape
);
index_shape
);
}
else
{
}
else
{
ret
=
xpu
::
gather_nd
<
T
,
int64_t
>
(
ctx
.
x_context
(),
ret
=
xpu
::
gather_nd
<
XPUType
,
int64_t
>
(
x
.
data
<
T
>
(),
ctx
.
x_context
(),
reinterpret_cast
<
const
XPUType
*>
(
x
.
data
<
T
>
()),
index
.
data
<
int64_t
>
(),
index
.
data
<
int64_t
>
(),
out
->
data
<
T
>
(
),
reinterpret_cast
<
XPUType
*>
(
out
->
data
<
T
>
()
),
x_vec
,
x_vec
,
index_shape
);
index_shape
);
}
}
...
@@ -106,5 +109,11 @@ void GatherNdKernel(const Context &ctx,
...
@@ -106,5 +109,11 @@ void GatherNdKernel(const Context &ctx,
}
// namespace phi
}
// namespace phi
PD_REGISTER_KERNEL
(
PD_REGISTER_KERNEL
(
gather_nd
,
gather_nd
,
XPU
,
ALL_LAYOUT
,
phi
::
GatherNdKernel
,
float
,
int64_t
,
int
)
{}
XPU
,
ALL_LAYOUT
,
phi
::
GatherNdKernel
,
float
,
int64_t
,
int
,
phi
::
dtype
::
float16
)
{}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录