Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
48ccb785
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
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看板
未验证
提交
48ccb785
编写于
4月 13, 2023
作者:
S
superwinner1
提交者:
GitHub
4月 13, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【Hackathon No.55】 add channel_shuffle FP16/BF16 support and tests (#51884)
* No55 add channel_shuffle FP16/BF16 support and tests
上级
205094f0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
5 deletion
+60
-5
paddle/phi/kernels/channel_shuffle_grad_kernel.h
paddle/phi/kernels/channel_shuffle_grad_kernel.h
+0
-1
paddle/phi/kernels/gpu/channel_shuffle_grad_kernel.cu
paddle/phi/kernels/gpu/channel_shuffle_grad_kernel.cu
+3
-1
paddle/phi/kernels/gpu/channel_shuffle_kernel.cu
paddle/phi/kernels/gpu/channel_shuffle_kernel.cu
+3
-1
python/paddle/fluid/tests/unittests/test_channel_shuffle.py
python/paddle/fluid/tests/unittests/test_channel_shuffle.py
+54
-2
未找到文件。
paddle/phi/kernels/channel_shuffle_grad_kernel.h
浏览文件 @
48ccb785
...
...
@@ -17,7 +17,6 @@
#include <string>
#include "paddle/phi/core/dense_tensor.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
...
...
paddle/phi/kernels/gpu/channel_shuffle_grad_kernel.cu
浏览文件 @
48ccb785
...
...
@@ -23,4 +23,6 @@ PD_REGISTER_KERNEL(channel_shuffle_grad,
ALL_LAYOUT
,
phi
::
ChannelShuffleGradKernel
,
float
,
double
)
{}
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
paddle/phi/kernels/gpu/channel_shuffle_kernel.cu
浏览文件 @
48ccb785
...
...
@@ -23,4 +23,6 @@ PD_REGISTER_KERNEL(channel_shuffle,
ALL_LAYOUT
,
phi
::
ChannelShuffleKernel
,
float
,
double
)
{}
double
,
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{}
python/paddle/fluid/tests/unittests/test_channel_shuffle.py
浏览文件 @
48ccb785
...
...
@@ -15,7 +15,7 @@
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.nn.functional
as
F
...
...
@@ -45,6 +45,7 @@ def channel_shuffle_np(x, groups, data_format="NCHW"):
class
TestChannelShuffleOp
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"channel_shuffle"
self
.
init_dtype
()
self
.
init_data_format
()
n
,
c
,
h
,
w
=
2
,
9
,
4
,
4
self
.
python_api
=
paddle
.
nn
.
functional
.
channel_shuffle
...
...
@@ -56,13 +57,16 @@ class TestChannelShuffleOp(OpTest):
groups
=
3
x
=
np
.
random
.
random
(
shape
).
astype
(
"float64"
)
x
=
np
.
random
.
random
(
shape
).
astype
(
self
.
dtype
)
npresult
=
channel_shuffle_np
(
x
,
groups
,
self
.
format
)
self
.
inputs
=
{
'X'
:
x
}
self
.
outputs
=
{
'Out'
:
npresult
}
self
.
attrs
=
{
'groups'
:
groups
,
"data_format"
:
self
.
format
}
def
init_dtype
(
self
):
self
.
dtype
=
'float64'
def
init_data_format
(
self
):
self
.
format
=
"NCHW"
...
...
@@ -268,5 +272,53 @@ class TestChannelShuffleError(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
error_data_format_layer
)
class
TestChannelShuffleFP16OP
(
TestChannelShuffleOp
):
def
init_dtype
(
self
):
self
.
dtype
=
np
.
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
TestChannelShuffleBF16OP
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"channel_shuffle"
self
.
init_data_format
()
n
,
c
,
h
,
w
=
2
,
9
,
4
,
4
self
.
python_api
=
paddle
.
nn
.
functional
.
channel_shuffle
self
.
dtype
=
np
.
uint16
self
.
use_mkldnn
=
False
if
self
.
format
==
"NCHW"
:
shape
=
[
n
,
c
,
h
,
w
]
if
self
.
format
==
"NHWC"
:
shape
=
[
n
,
h
,
w
,
c
]
groups
=
3
x
=
np
.
random
.
random
(
shape
).
astype
(
'float32'
)
out
=
channel_shuffle_np
(
x
,
groups
,
self
.
format
)
self
.
inputs
=
{
'X'
:
convert_float_to_uint16
(
x
)}
self
.
attrs
=
{
'groups'
:
groups
,
"data_format"
:
self
.
format
}
self
.
outputs
=
{
'Out'
:
convert_float_to_uint16
(
out
)}
def
init_data_format
(
self
):
self
.
format
=
"NCHW"
def
test_check_output
(
self
):
place
=
core
.
CUDAPlace
(
0
)
self
.
check_output_with_place
(
place
)
def
test_check_grad
(
self
):
place
=
core
.
CUDAPlace
(
0
)
self
.
check_grad_with_place
(
place
,
[
'X'
],
'Out'
,
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录