Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f547ee92
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f547ee92
编写于
4月 03, 2023
作者:
C
chenxujun
提交者:
GitHub
4月 03, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add kron float16/bfloat16, unbind float16 tests (#52413)
上级
3c949ba9
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
1 deletion
+72
-1
paddle/phi/kernels/gpu/kron_grad_kernel.cu
paddle/phi/kernels/gpu/kron_grad_kernel.cu
+1
-0
paddle/phi/kernels/gpu/kron_kernel.cu
paddle/phi/kernels/gpu/kron_kernel.cu
+1
-0
python/paddle/fluid/tests/unittests/test_kron_op.py
python/paddle/fluid/tests/unittests/test_kron_op.py
+46
-1
python/paddle/fluid/tests/unittests/test_unbind_op.py
python/paddle/fluid/tests/unittests/test_unbind_op.py
+24
-0
未找到文件。
paddle/phi/kernels/gpu/kron_grad_kernel.cu
浏览文件 @
f547ee92
...
...
@@ -27,5 +27,6 @@ PD_REGISTER_KERNEL(kron_grad,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
)
{}
paddle/phi/kernels/gpu/kron_kernel.cu
浏览文件 @
f547ee92
...
...
@@ -27,5 +27,6 @@ PD_REGISTER_KERNEL(kron,
float
,
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
)
{}
python/paddle/fluid/tests/unittests/test_kron_op.py
浏览文件 @
f547ee92
...
...
@@ -15,11 +15,12 @@
import
unittest
import
numpy
as
np
from
eager_op_test
import
OpTest
from
eager_op_test
import
OpTest
,
convert_float_to_uint16
import
paddle
import
paddle.fluid.dygraph
as
dg
from
paddle
import
fluid
from
paddle.fluid
import
core
class
TestKronOp
(
OpTest
):
...
...
@@ -73,6 +74,50 @@ class TestKronOp3(TestKronOp):
self
.
outputs
=
{
'Out'
:
out_ref
}
class
TestKronFP16Op
(
TestKronOp
):
def
_init_dtype
(
self
):
return
"float16"
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
is_bfloat16_supported
(
core
.
CUDAPlace
(
0
)),
"core is not complied with CUDA and not support the bfloat16"
,
)
class
TestKronBF16Op
(
TestKronOp
):
def
setUp
(
self
):
self
.
op_type
=
"kron"
self
.
python_api
=
paddle
.
kron
self
.
dtype
=
np
.
uint16
self
.
np_dtype
=
"float32"
x
=
np
.
random
.
uniform
(
size
=
(
10
,
10
)).
astype
(
self
.
np_dtype
)
y
=
np
.
random
.
uniform
(
size
=
(
10
,
10
)).
astype
(
self
.
np_dtype
)
out_ref
=
np
.
kron
(
x
,
y
)
self
.
inputs
=
{
'X'
:
convert_float_to_uint16
(
x
),
'Y'
:
convert_float_to_uint16
(
y
),
}
self
.
outputs
=
{
'Out'
:
convert_float_to_uint16
(
out_ref
)}
# bfloat16 requires using place
self
.
place
=
core
.
CUDAPlace
(
0
)
def
test_check_output
(
self
):
self
.
check_output_with_place
(
self
.
place
)
def
test_check_grad
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
,
'Y'
],
'Out'
)
def
test_check_grad_ignore_x
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'Y'
],
'Out'
,
no_grad_set
=
set
(
'X'
)
)
def
test_check_grad_ignore_y
(
self
):
self
.
check_grad_with_place
(
self
.
place
,
[
'X'
],
'Out'
,
no_grad_set
=
set
(
'Y'
)
)
class
TestKronLayer
(
unittest
.
TestCase
):
def
test_case
(
self
):
a
=
np
.
random
.
randn
(
10
,
10
).
astype
(
np
.
float64
)
...
...
python/paddle/fluid/tests/unittests/test_unbind_op.py
浏览文件 @
f547ee92
...
...
@@ -199,6 +199,30 @@ class TestUnbindOp4(TestUnbindOp):
self
.
out
[
1
]
=
self
.
out
[
1
].
reshape
((
3
,
2
))
class
TestUnbindFP16Op
(
OpTest
):
def
setUp
(
self
):
paddle
.
disable_static
()
self
.
op_type
=
"unbind"
self
.
python_api
=
paddle
.
unbind
self
.
dtype
=
self
.
get_dtype
()
self
.
axis
=
0
self
.
num
=
3
x
=
np
.
arange
(
12
).
reshape
(
3
,
2
,
2
).
astype
(
self
.
dtype
)
self
.
out
=
np
.
split
(
x
,
self
.
num
,
self
.
axis
)
self
.
inputs
=
{
'X'
:
x
}
self
.
attrs
=
{
'axis'
:
self
.
axis
}
self
.
outputs
=
{
'Out'
:
[(
'out%d'
%
i
,
self
.
out
[
i
])
for
i
in
range
(
len
(
self
.
out
))]
}
self
.
python_out_sig
=
[
'out%d'
%
i
for
i
in
range
(
len
(
self
.
out
))]
def
get_dtype
(
self
):
return
np
.
float16
def
test_check_output
(
self
):
self
.
check_output
()
class
TestUnbindBF16Op
(
OpTest
):
def
setUp
(
self
):
paddle
.
disable_static
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录