Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
26331724
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
26331724
编写于
7月 31, 2023
作者:
R
Ruibin Cheung
提交者:
GitHub
7月 31, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(ut): nearest interp v2 op unit test (#55677)
上级
ada393b3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
90 addition
and
13 deletion
+90
-13
test/legacy_test/test_nearest_interp_op.py
test/legacy_test/test_nearest_interp_op.py
+23
-3
test/legacy_test/test_nearest_interp_v2_op.py
test/legacy_test/test_nearest_interp_v2_op.py
+23
-3
test/xpu/test_nearest_interp_op_xpu.py
test/xpu/test_nearest_interp_op_xpu.py
+22
-4
test/xpu/test_nearest_interp_v2_op_xpu.py
test/xpu/test_nearest_interp_v2_op_xpu.py
+22
-3
未找到文件。
test/legacy_test/test_nearest_interp_op.py
浏览文件 @
26331724
...
...
@@ -346,10 +346,11 @@ class TestNearestInterpOp_attr_tensor(OpTest):
def
setUp
(
self
):
self
.
out_size
=
None
self
.
actual_shape
=
None
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp"
self
.
shape_by_1Dtensor
=
False
self
.
scale_by_1Dtensor
=
False
self
.
scale_by_2Dtensor
=
False
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp_v2"
self
.
attrs
=
{
'interp_method'
:
self
.
interp_method
,
'align_corners'
:
self
.
align_corners
,
...
...
@@ -359,7 +360,13 @@ class TestNearestInterpOp_attr_tensor(OpTest):
self
.
inputs
=
{
'X'
:
input_np
}
if
self
.
scale_by_1Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float64"
)
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float32"
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
)
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
)
elif
self
.
scale_by_2Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
(
self
.
scale
).
astype
(
"float32"
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
[
0
])
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
[
1
])
elif
self
.
scale
>
0
:
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
)
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
)
...
...
@@ -444,6 +451,19 @@ class TestNearestInterp_attr_tensor_Case3(TestNearestInterpOp_attr_tensor):
self
.
scale_by_1Dtensor
=
True
# scale is a 2-D tensor
class
TestNearestInterp_attr_tensor_Case4
(
TestNearestInterpOp_attr_tensor
):
def
init_test_case
(
self
):
self
.
interp_method
=
'nearest'
self
.
input_shape
=
[
3
,
2
,
32
,
16
]
self
.
out_h
=
64
self
.
out_w
=
32
self
.
scale
=
[
2.0
,
2.0
]
self
.
out_size
=
None
self
.
align_corners
=
True
self
.
scale_by_2Dtensor
=
True
if
__name__
==
"__main__"
:
import
paddle
...
...
test/legacy_test/test_nearest_interp_v2_op.py
浏览文件 @
26331724
...
...
@@ -827,10 +827,11 @@ class TestNearestInterpOp_attr_tensor(OpTest):
self
.
python_api
=
nearest_interp_test
self
.
out_size
=
None
self
.
actual_shape
=
None
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp_v2"
self
.
shape_by_1Dtensor
=
False
self
.
scale_by_1Dtensor
=
False
self
.
scale_by_2Dtensor
=
False
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp_v2"
self
.
attrs
=
{
'interp_method'
:
self
.
interp_method
,
'align_corners'
:
self
.
align_corners
,
...
...
@@ -840,7 +841,13 @@ class TestNearestInterpOp_attr_tensor(OpTest):
self
.
inputs
=
{
'X'
:
input_np
}
if
self
.
scale_by_1Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float64"
)
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float32"
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
)
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
)
elif
self
.
scale_by_2Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
(
self
.
scale
).
astype
(
"float32"
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
[
0
])
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
[
1
])
elif
self
.
scale
:
if
isinstance
(
self
.
scale
,
float
)
or
isinstance
(
self
.
scale
,
int
):
if
self
.
scale
>
0
:
...
...
@@ -941,6 +948,19 @@ class TestNearestInterp_attr_tensor_Case3(TestNearestInterpOp_attr_tensor):
self
.
scale_by_1Dtensor
=
True
# scale is a 2-D tensor
class
TestNearestInterp_attr_tensor_Case4
(
TestNearestInterpOp_attr_tensor
):
def
init_test_case
(
self
):
self
.
interp_method
=
'nearest'
self
.
input_shape
=
[
3
,
2
,
32
,
16
]
self
.
out_h
=
64
self
.
out_w
=
32
self
.
scale
=
[
2.0
,
2.0
]
self
.
out_size
=
None
self
.
align_corners
=
True
self
.
scale_by_2Dtensor
=
True
class
TestNearestInterpOpAPI_dy
(
unittest
.
TestCase
):
def
test_case
(
self
):
import
paddle
...
...
test/xpu/test_nearest_interp_op_xpu.py
浏览文件 @
26331724
...
...
@@ -297,10 +297,11 @@ class TestNearestInterpOp_attr_tensor(XPUOpTest):
def setUp(self):
self.out_size = None
self.actual_shape = None
self.init_test_case()
self.op_type = "nearest_interp"
self.shape_by_1Dtensor = False
self.scale_by_1Dtensor = False
self.scale_by_2Dtensor = False
self.init_test_case()
self.op_type = "nearest_interp"
self.attrs = {
"interp_method": self.interp_method,
"align_corners": self.align_corners,
...
...
@@ -311,10 +312,12 @@ class TestNearestInterpOp_attr_tensor(XPUOpTest):
if self.scale_by_1Dtensor:
self.inputs["Scale"] = np.array([self.scale]).astype("float32")
elif self.scale > 0:
out_h = int(self.input_shape[2] * self.scale)
out_w = int(self.input_shape[3] * self.scale)
self.attrs["scale"] = self.scale
elif self.scale_by_2Dtensor:
self.inputs['Scale'] = np.array(self.scale).astype("float32")
out_h = int(self.input_shape[2] * self.scale[0])
out_w = int(self.input_shape[3] * self.scale[1])
else:
out_h = self.out_h
out_w = self.out_w
...
...
@@ -397,6 +400,21 @@ class TestNearestInterp_attr_tensor_Case3(TestNearestInterpOp_attr_tensor):
self.scale_by_1Dtensor = True
# scale is a 2-D tensor
@unittest.skipIf(not paddle.is_compiled_with_xpu(),
"core is not compiled with XPU")
class TestNearestInterp_attr_tensor_Case4(TestNearestInterpOp_attr_tensor):
def init_test_case(self):
self.interp_method = 'nearest'
self.input_shape = [3, 2, 32, 16]
self.out_h = 64
self.out_w = 32
self.scale = [2.0, 2.0]
self.out_size = None
self.align_corners = True
self.scale_by_2Dtensor = True
@unittest.skipIf(not paddle.is_compiled_with_xpu(),
"core is not compiled with XPU")
class TestNearestInterpException(unittest.TestCase):
...
...
test/xpu/test_nearest_interp_v2_op_xpu.py
浏览文件 @
26331724
...
...
@@ -431,10 +431,11 @@ class XPUNearestInterpOpWrapper(XPUOpTestWrapper):
self
.
scale
=
0.0
self
.
align_corners
=
True
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp_v2"
self
.
shape_by_1Dtensor
=
False
self
.
scale_by_1Dtensor
=
False
self
.
scale_by_2Dtensor
=
False
self
.
init_test_case
()
self
.
op_type
=
"nearest_interp_v2"
self
.
attrs
=
{
'interp_method'
:
self
.
interp_method
,
'align_corners'
:
self
.
align_corners
,
...
...
@@ -444,7 +445,13 @@ class XPUNearestInterpOpWrapper(XPUOpTestWrapper):
self
.
inputs
=
{
'X'
:
input_np
}
if
self
.
scale_by_1Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float32"
)
self
.
inputs
[
"Scale"
]
=
np
.
array
([
self
.
scale
]).
astype
(
"float32"
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
)
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
)
elif
self
.
scale_by_2Dtensor
:
self
.
inputs
[
'Scale'
]
=
np
.
array
(
self
.
scale
).
astype
(
"float32"
)
out_h
=
int
(
self
.
input_shape
[
2
]
*
self
.
scale
[
0
])
out_w
=
int
(
self
.
input_shape
[
3
]
*
self
.
scale
[
1
])
elif
self
.
scale
:
if
isinstance
(
self
.
scale
,
(
float
,
int
)):
if
self
.
scale
>
0
:
...
...
@@ -533,6 +540,18 @@ class XPUNearestInterpOpWrapper(XPUOpTestWrapper):
self
.
out_size
=
None
self
.
scale_by_1Dtensor
=
True
# scale is a 2-D tensor
class
TestNearestInterp_attr_tensor_Case4
(
TestNearestInterpOp_attr_tensor
):
def
init_test_case
(
self
):
self
.
interp_method
=
'nearest'
self
.
input_shape
=
[
3
,
2
,
32
,
16
]
self
.
out_h
=
64
self
.
out_w
=
32
self
.
scale
=
[
2.0
,
2.0
]
self
.
out_size
=
None
self
.
align_corners
=
True
self
.
scale_by_2Dtensor
=
True
support_types
=
get_xpu_op_support_types
(
'nearest_interp_v2'
)
for
stype
in
support_types
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录