Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2a0bd17c
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看板
未验证
提交
2a0bd17c
编写于
3月 20, 2023
作者:
FormlessUnit
提交者:
GitHub
3月 20, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fill_constant_batch_size_like support bf16 (#51396)
shape support bf16
上级
b2385821
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
72 addition
and
4 deletion
+72
-4
paddle/phi/kernels/full_kernel.cc
paddle/phi/kernels/full_kernel.cc
+2
-1
paddle/phi/kernels/shape_kernel.cc
paddle/phi/kernels/shape_kernel.cc
+2
-1
python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like.py
...uid/tests/unittests/test_fill_constant_batch_size_like.py
+43
-1
python/paddle/fluid/tests/unittests/test_shape_op.py
python/paddle/fluid/tests/unittests/test_shape_op.py
+25
-1
未找到文件。
paddle/phi/kernels/full_kernel.cc
浏览文件 @
2a0bd17c
...
...
@@ -59,7 +59,8 @@ PD_REGISTER_KERNEL(full_batch_size_like,
int
,
int64_t
,
bool
,
phi
::
dtype
::
float16
)
{
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{
kernel
->
InputAt
(
0
).
SetBackend
(
phi
::
Backend
::
ALL_BACKEND
);
}
#endif
paddle/phi/kernels/shape_kernel.cc
浏览文件 @
2a0bd17c
...
...
@@ -65,7 +65,8 @@ PD_REGISTER_KERNEL(shape,
double
,
phi
::
dtype
::
complex
<
float
>
,
phi
::
dtype
::
complex
<
double
>
,
phi
::
dtype
::
float16
)
{
phi
::
dtype
::
float16
,
phi
::
dtype
::
bfloat16
)
{
kernel
->
InputAt
(
0
).
SetBackend
(
phi
::
Backend
::
ALL_BACKEND
);
kernel
->
OutputAt
(
0
).
SetBackend
(
phi
::
Backend
::
CPU
);
kernel
->
OutputAt
(
0
).
SetDataType
(
phi
::
DataType
::
INT32
);
...
...
python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like.py
浏览文件 @
2a0bd17c
...
...
@@ -15,9 +15,10 @@
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.core
as
core
from
paddle.fluid.framework
import
convert_np_dtype_to_dtype_
paddle
.
enable_static
()
...
...
@@ -70,5 +71,46 @@ class TestFillConstatnBatchSizeLike1(OpTest):
self
.
check_output
()
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
supports_bfloat16
(),
"core is not compiled with CUDA or place do not support bfloat16"
,
)
class
TestFillConstatnBatchSizeLikeBf16
(
OpTest
):
# test bf16
def
setUp
(
self
):
self
.
op_type
=
"fill_constant_batch_size_like"
self
.
python_api
=
fill_constant_batch_size_like
self
.
init_data
()
input
=
np
.
zeros
(
self
.
shape
).
astype
(
"float32"
)
input_bf16
=
convert_float_to_uint16
(
input
)
out
=
np
.
full_like
(
input
,
self
.
value
,
np
.
float32
)
out_bf16
=
convert_float_to_uint16
(
out
)
self
.
inputs
=
{
'Input'
:
input_bf16
}
self
.
outputs
=
{
'Out'
:
out_bf16
}
self
.
attrs
=
{
'shape'
:
self
.
shape
,
'dtype'
:
convert_np_dtype_to_dtype_
(
self
.
dtype
),
'value'
:
self
.
value
,
'input_dim_idx'
:
self
.
input_dim_idx
,
'output_dim_idx'
:
self
.
output_dim_idx
,
'force_cpu'
:
self
.
force_cpu
,
}
def
init_data
(
self
):
self
.
shape
=
[
10
,
10
]
self
.
dtype
=
np
.
uint16
self
.
value
=
100
self
.
input_dim_idx
=
0
self
.
output_dim_idx
=
0
self
.
force_cpu
=
False
def
test_check_output
(
self
):
place
=
core
.
CUDAPlace
(
0
)
self
.
check_output_with_place
(
place
)
if
__name__
==
"__main__"
:
paddle
.
enable_static
()
unittest
.
main
()
python/paddle/fluid/tests/unittests/test_shape_op.py
浏览文件 @
2a0bd17c
...
...
@@ -15,7 +15,7 @@
import
unittest
import
numpy
as
np
from
op_test
import
OpTest
from
op_test
import
OpTest
,
convert_float_to_uint16
import
paddle
from
paddle.fluid
import
core
...
...
@@ -85,5 +85,29 @@ class TestShapeWithSelectedRows(unittest.TestCase):
self
.
check_with_place
(
place
)
@
unittest
.
skipIf
(
not
core
.
is_compiled_with_cuda
()
or
not
core
.
supports_bfloat16
(),
"core is not compiled with CUDA or place do not support bfloat16"
,
)
class
TestShapeOpBf16
(
OpTest
):
def
setUp
(
self
):
self
.
op_type
=
"shape"
self
.
dtype
=
'bfloat16'
self
.
python_api
=
paddle
.
shape
self
.
config
()
self
.
shape
=
[
2
,
3
]
input
=
np
.
zeros
(
self
.
shape
)
input
=
convert_float_to_uint16
(
input
.
astype
(
'float32'
))
self
.
inputs
=
{
'Input'
:
input
}
self
.
outputs
=
{
'Out'
:
np
.
array
(
self
.
shape
)}
def
config
(
self
):
self
.
shape
=
[
2
,
3
]
def
test_check_output
(
self
):
place
=
core
.
CUDAPlace
(
0
)
self
.
check_output_with_place
(
place
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录