Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
9d4b4be3
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看板
未验证
提交
9d4b4be3
编写于
11月 29, 2022
作者:
H
haosicheng
提交者:
GitHub
11月 29, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add floor fp32 op *test=kunlun (#48458)
上级
a66bb67a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
0 deletion
+42
-0
paddle/fluid/platform/device/xpu/xpu2_op_list.h
paddle/fluid/platform/device/xpu/xpu2_op_list.h
+1
-0
paddle/phi/kernels/xpu/activation_kernel.cc
paddle/phi/kernels/xpu/activation_kernel.cc
+15
-0
python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py
...addle/fluid/tests/unittests/xpu/test_activation_op_xpu.py
+26
-0
未找到文件。
paddle/fluid/platform/device/xpu/xpu2_op_list.h
浏览文件 @
9d4b4be3
...
...
@@ -282,6 +282,7 @@ XPUOpMap& get_kl2_ops() {
pOpKernelType
(
vartype
::
INT32
,
XPUPlace
()),
pOpKernelType
(
vartype
::
INT8
,
XPUPlace
()),
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
())})},
{
"floor"
,
XPUKernelSet
({
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
())})},
{
"gather_grad"
,
XPUKernelSet
({
pOpKernelType
(
vartype
::
FP32
,
XPUPlace
()),
pOpKernelType
(
vartype
::
FP16
,
XPUPlace
())})},
...
...
paddle/phi/kernels/xpu/activation_kernel.cc
浏览文件 @
9d4b4be3
...
...
@@ -426,7 +426,21 @@ struct XPUTanhFunctor : public funcs::BaseActivationFunctor<T> {
}
};
template
<
typename
T
>
struct
XPUFloorFunctor
:
public
funcs
::
BaseActivationFunctor
<
T
>
{
using
XPUType
=
typename
XPUTypeTrait
<
T
>::
Type
;
template
<
typename
Context
>
void
operator
()(
const
Context
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
const
{
int
r
=
xpu_activation_func
<
Context
,
T
,
XPUType
>
(
dev_ctx
,
x
,
out
,
xpu
::
floor
<
XPUType
>
);
PADDLE_ENFORCE_XDNN_SUCCESS
(
r
,
"floor"
);
}
};
DEFINE_XPU_ACTIVATION_KERNEL
(
Exp
,
XPUExpFunctor
)
DEFINE_XPU_ACTIVATION_KERNEL
(
Floor
,
XPUFloorFunctor
)
DEFINE_XPU_ACTIVATION_KERNEL
(
Log
,
XPULogFunctor
)
DEFINE_XPU_ACTIVATION_KERNEL
(
Reciprocal
,
XPUReciprocalFunctor
)
DEFINE_XPU_ACTIVATION_KERNEL
(
Relu
,
XPUReluFunctor
)
...
...
@@ -483,6 +497,7 @@ PD_REGISTER_KERNEL(
square
,
XPU
,
ALL_LAYOUT
,
phi
::
SquareKernel
,
float
,
phi
::
dtype
::
float16
)
{}
PD_REGISTER_ACTIVATION_KERNEL
(
exp
,
ExpKernel
)
// no grad
PD_REGISTER_ACTIVATION_KERNEL
(
floor
,
FloorKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
log
,
LogKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
leaky_relu
,
LeakyReluKernel
)
PD_REGISTER_ACTIVATION_KERNEL
(
hard_sigmoid
,
HardSigmoidKernel
)
...
...
python/paddle/fluid/tests/unittests/xpu/test_activation_op_xpu.py
浏览文件 @
9d4b4be3
...
...
@@ -177,6 +177,32 @@ for stype in support_types:
create_test_class
(
globals
(),
XPUTestSqrtOP
,
stype
)
class
XPUTestFloorOP
(
XPUOpTestWrapper
):
def
__init__
(
self
):
self
.
op_name
=
'floor'
self
.
use_dynamic_create_class
=
False
class
XPUTestSqrt
(
TestActivationOPBase
):
def
set_case
(
self
):
self
.
op_type
=
"floor"
self
.
dtype
=
self
.
in_type
x
=
np
.
random
.
uniform
(
0.1
,
1
,
[
11
,
17
]).
astype
(
self
.
dtype
)
out
=
np
.
floor
(
x
)
self
.
attrs
=
{
'use_xpu'
:
True
}
self
.
inputs
=
{
'X'
:
OpTest
.
np_dtype_to_fluid_dtype
(
x
)}
self
.
outputs
=
{
'Out'
:
out
}
def
test_check_grad
(
self
):
self
.
check_output_with_place
(
self
.
place
)
support_types
=
get_xpu_op_support_types
(
'floor'
)
for
stype
in
support_types
:
create_test_class
(
globals
(),
XPUTestFloorOP
,
stype
)
class
XPUTestAbsOP
(
XPUOpTestWrapper
):
def
__init__
(
self
):
self
.
op_name
=
'abs'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录