Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
3161e6c3
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看板
未验证
提交
3161e6c3
编写于
3月 30, 2023
作者:
zhenhailiu
提交者:
GitHub
3月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[AMP OP&Test] Arg min max bf16 test (#52276)
* polish * add type check
上级
bed54a70
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
54 addition
and
1 deletion
+54
-1
python/paddle/fluid/tests/unittests/test_arg_min_max_op.py
python/paddle/fluid/tests/unittests/test_arg_min_max_op.py
+52
-1
python/paddle/tensor/search.py
python/paddle/tensor/search.py
+2
-0
未找到文件。
python/paddle/fluid/tests/unittests/test_arg_min_max_op.py
浏览文件 @
3161e6c3
...
...
@@ -16,7 +16,7 @@ import os
import
unittest
import
numpy
as
np
from
eager_op_test
import
OpTest
from
eager_op_test
import
OpTest
,
convert_float_to_uint16
from
test_attribute_var
import
UnittestBase
import
paddle
...
...
@@ -96,6 +96,57 @@ class TestCase1FP16(BaseTestCase):
self
.
axis
=
1
@
unittest
.
skipIf
(
not
paddle
.
is_compiled_with_cuda
(),
"BFP16 test runs only on GPU"
)
class
TestArgMinBF16OP
(
OpTest
):
def
initTestType
(
self
):
self
.
op_type
=
'arg_min'
self
.
python_api
=
paddle
.
tensor
.
argmin
def
initTestCase
(
self
):
self
.
initTestType
()
self
.
dims
=
(
3
,
4
,
5
)
self
.
axis
=
0
self
.
dtype
=
np
.
uint16
def
setUp
(
self
):
self
.
initTestCase
()
x
=
np
.
random
.
random
(
self
.
dims
).
astype
(
"float32"
)
self
.
x
=
convert_float_to_uint16
(
x
)
self
.
inputs
=
{
'X'
:
self
.
x
}
self
.
attrs
=
{
'axis'
:
self
.
axis
}
if
self
.
op_type
==
"arg_min"
:
self
.
outputs
=
{
'Out'
:
np
.
argmin
(
x
,
axis
=
self
.
axis
)}
else
:
self
.
outputs
=
{
'Out'
:
np
.
argmax
(
x
,
axis
=
self
.
axis
)}
def
test_check_output
(
self
):
self
.
check_output_with_place
(
paddle
.
CUDAPlace
(
0
))
class
TestArgMaxBF16OP
(
TestArgMinBF16OP
):
def
initTestType
(
self
):
self
.
op_type
=
'arg_max'
self
.
python_api
=
paddle
.
tensor
.
argmax
class
TestArgMinMaxTypeCheck
(
unittest
.
TestCase
):
def
test_type_error
(
self
):
# in static mode
with
program_guard
(
Program
(),
Program
()):
x
=
paddle
.
static
.
data
(
name
=
'x'
,
shape
=
[
100
,
10
],
dtype
=
'bool'
)
self
.
assertRaises
(
TypeError
,
paddle
.
argmin
,
x
)
self
.
assertRaises
(
TypeError
,
paddle
.
argmax
,
x
)
def
test_bfp16
(
self
):
# in static mode
with
program_guard
(
Program
(),
Program
()):
x
=
paddle
.
zeros
(
name
=
'x'
,
shape
=
[
100
,
10
],
dtype
=
'uint16'
)
t1
=
paddle
.
argmin
(
x
)
t2
=
paddle
.
argmax
(
x
)
class
TestCase2_1
(
BaseTestCase
):
def
initTestCase
(
self
):
self
.
op_type
=
'arg_max'
...
...
python/paddle/tensor/search.py
浏览文件 @
3161e6c3
...
...
@@ -194,6 +194,7 @@ def argmax(x, axis=None, keepdim=False, dtype="int64", name=None):
x
,
'x'
,
[
'uint16'
,
'float16'
,
'float32'
,
'float64'
,
...
...
@@ -283,6 +284,7 @@ def argmin(x, axis=None, keepdim=False, dtype="int64", name=None):
x
,
'x'
,
[
'uint16'
,
'float16'
,
'float32'
,
'float64'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录