Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
91c0f727
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
91c0f727
编写于
7月 04, 2022
作者:
C
Chenxiao Niu
提交者:
GitHub
7月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[MLU] uncomment some interp_v2 tests. (#44053)
上级
bd06a828
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
110 addition
and
95 deletion
+110
-95
python/paddle/fluid/tests/unittests/mlu/test_bilinear_interp_v2_op_mlu.py
...uid/tests/unittests/mlu/test_bilinear_interp_v2_op_mlu.py
+49
-45
python/paddle/fluid/tests/unittests/mlu/test_nearest_interp_v2_op_mlu.py
...luid/tests/unittests/mlu/test_nearest_interp_v2_op_mlu.py
+61
-50
未找到文件。
python/paddle/fluid/tests/unittests/mlu/test_bilinear_interp_v2_op_mlu.py
浏览文件 @
91c0f727
...
...
@@ -515,51 +515,55 @@ class TestBilinearInterp_attr_tensor_Case3(TestBilinearInterpOp_attr_tensor):
self
.
scale_by_1Dtensor
=
True
#TODO: comment this test for now until bilinear_interp_op added.
# class TestBilinearInterpOpAPI(unittest.TestCase):
# def test_case(self):
# x = fluid.data(name="x", shape=[2, 3, 6, 6], dtype="float32")
# dim = fluid.data(name="dim", shape=[1], dtype="int32")
# shape_tensor = fluid.data(name="shape_tensor", shape=[2], dtype="int32")
# actual_size = fluid.data(name="actual_size", shape=[2], dtype="int32")
# scale_tensor = fluid.data(
# name="scale_tensor", shape=[1], dtype="float32")
# out1 = fluid.layers.resize_bilinear(x, out_shape=[12, 12])
# out2 = fluid.layers.resize_bilinear(x, out_shape=[12, dim])
# out3 = fluid.layers.resize_bilinear(x, out_shape=shape_tensor)
# out4 = fluid.layers.resize_bilinear(
# x, out_shape=[4, 4], actual_shape=actual_size)
# out5 = fluid.layers.resize_bilinear(x, scale=scale_tensor)
# x_data = np.random.random((2, 3, 6, 6)).astype("float32")
# dim_data = np.array([12]).astype("int32")
# shape_data = np.array([12, 12]).astype("int32")
# actual_size_data = np.array([12, 12]).astype("int32")
# scale_data = np.array([2.0]).astype("float32")
# if core.is_compiled_with_mlu():
# place = paddle.device.MLUPlace(0)
# else:
# place = core.CPUPlace()
# exe = fluid.Executor(place)
# exe.run(fluid.default_startup_program())
# results = exe.run(fluid.default_main_program(),
# feed={
# "x": x_data,
# "dim": dim_data,
# "shape_tensor": shape_data,
# "actual_size": actual_size_data,
# "scale_tensor": scale_data
# },
# fetch_list=[out1, out2, out3, out4, out5],
# return_numpy=True)
# expect_res = bilinear_interp_np(
# x_data, out_h=12, out_w=12, align_corners=True)
# for res in results:
# self.assertTrue(np.allclose(res, expect_res))
class
TestBilinearInterpOpAPI
(
unittest
.
TestCase
):
def
test_case
(
self
):
x
=
fluid
.
data
(
name
=
"x"
,
shape
=
[
2
,
3
,
6
,
6
],
dtype
=
"float32"
)
dim
=
fluid
.
data
(
name
=
"dim"
,
shape
=
[
1
],
dtype
=
"int32"
)
shape_tensor
=
fluid
.
data
(
name
=
"shape_tensor"
,
shape
=
[
2
],
dtype
=
"int32"
)
actual_size
=
fluid
.
data
(
name
=
"actual_size"
,
shape
=
[
2
],
dtype
=
"int32"
)
scale_tensor
=
fluid
.
data
(
name
=
"scale_tensor"
,
shape
=
[
1
],
dtype
=
"float32"
)
out1
=
fluid
.
layers
.
resize_bilinear
(
x
,
out_shape
=
[
12
,
12
])
out2
=
fluid
.
layers
.
resize_bilinear
(
x
,
out_shape
=
[
12
,
dim
])
out3
=
fluid
.
layers
.
resize_bilinear
(
x
,
out_shape
=
shape_tensor
)
out4
=
fluid
.
layers
.
resize_bilinear
(
x
,
out_shape
=
[
4
,
4
],
actual_shape
=
actual_size
)
out5
=
fluid
.
layers
.
resize_bilinear
(
x
,
scale
=
scale_tensor
)
x_data
=
np
.
random
.
random
((
2
,
3
,
6
,
6
)).
astype
(
"float32"
)
dim_data
=
np
.
array
([
12
]).
astype
(
"int32"
)
shape_data
=
np
.
array
([
12
,
12
]).
astype
(
"int32"
)
actual_size_data
=
np
.
array
([
12
,
12
]).
astype
(
"int32"
)
scale_data
=
np
.
array
([
2.0
]).
astype
(
"float32"
)
if
core
.
is_compiled_with_mlu
():
place
=
paddle
.
device
.
MLUPlace
(
0
)
else
:
place
=
core
.
CPUPlace
()
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
results
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"x"
:
x_data
,
"dim"
:
dim_data
,
"shape_tensor"
:
shape_data
,
"actual_size"
:
actual_size_data
,
"scale_tensor"
:
scale_data
},
fetch_list
=
[
out1
,
out2
,
out3
,
out4
,
out5
],
return_numpy
=
True
)
expect_res
=
bilinear_interp_np
(
x_data
,
out_h
=
12
,
out_w
=
12
,
align_corners
=
True
)
for
res
in
results
:
self
.
assertTrue
(
np
.
allclose
(
res
,
expect_res
))
class
TestBilinearInterpOpAPI_dy
(
unittest
.
TestCase
):
...
...
python/paddle/fluid/tests/unittests/mlu/test_nearest_interp_v2_op_mlu.py
浏览文件 @
91c0f727
...
...
@@ -274,6 +274,7 @@ class TestNearestInterpOp(OpTest):
self
.
align_corners
=
True
# comment out since 5-D input not supported now
# class TestNearestNeighborInterpCase1(TestNearestInterpOp):
# def init_test_case(self):
# self.interp_method = 'nearest'
...
...
@@ -537,56 +538,66 @@ class TestNearestInterp_attr_tensor_Case3(TestNearestInterpOp_attr_tensor):
self
.
scale_by_1Dtensor
=
True
#TODO: comment this test for now until nearest_interp_op added.
# class TestNearestAPI(unittest.TestCase):
# def test_case(self):
# x = fluid.data(name="x", shape=[2, 3, 6, 6], dtype="float32")
# y = fluid.data(name="y", shape=[2, 6, 6, 3], dtype="float32")
# dim = fluid.data(name="dim", shape=[1], dtype="int32")
# shape_tensor = fluid.data(name="shape_tensor", shape=[2], dtype="int32")
# actual_size = fluid.data(name="actual_size", shape=[2], dtype="int32")
# scale_tensor = fluid.data(
# name="scale_tensor", shape=[1], dtype="float32")
# out1 = fluid.layers.resize_nearest(
# y, out_shape=[12, 12], data_format='NHWC', align_corners=False)
# out2 = fluid.layers.resize_nearest(
# x, out_shape=[12, dim], align_corners=False)
# out3 = fluid.layers.resize_nearest(
# x, out_shape=shape_tensor, align_corners=False)
# out4 = fluid.layers.resize_nearest(
# x, out_shape=[4, 4], actual_shape=actual_size, align_corners=False)
# out5 = fluid.layers.resize_nearest(
# x, scale=scale_tensor, align_corners=False)
# x_data = np.random.random((2, 3, 6, 6)).astype("float32")
# dim_data = np.array([12]).astype("int32")
# shape_data = np.array([12, 12]).astype("int32")
# actual_size_data = np.array([12, 12]).astype("int32")
# scale_data = np.array([2.0]).astype("float32")
# place = paddle.MLUPlace(0)
# exe = fluid.Executor(place)
# exe.run(fluid.default_startup_program())
# results = exe.run(fluid.default_main_program(),
# feed={
# "x": x_data,
# "y": np.transpose(x_data, (0, 2, 3, 1)),
# "dim": dim_data,
# "shape_tensor": shape_data,
# "actual_size": actual_size_data,
# "scale_tensor": scale_data
# },
# fetch_list=[out1, out2, out3, out4, out5],
# return_numpy=True)
# expect_res = nearest_neighbor_interp_np(
# x_data, out_h=12, out_w=12, align_corners=False)
# self.assertTrue(
# np.allclose(results[0], np.transpose(expect_res, (0, 2, 3, 1))))
# for i in range(len(results) - 1):
# self.assertTrue(np.allclose(results[i + 1], expect_res))
class
TestNearestAPI
(
unittest
.
TestCase
):
def
test_case
(
self
):
x
=
fluid
.
data
(
name
=
"x"
,
shape
=
[
2
,
3
,
6
,
6
],
dtype
=
"float32"
)
y
=
fluid
.
data
(
name
=
"y"
,
shape
=
[
2
,
6
,
6
,
3
],
dtype
=
"float32"
)
dim
=
fluid
.
data
(
name
=
"dim"
,
shape
=
[
1
],
dtype
=
"int32"
)
shape_tensor
=
fluid
.
data
(
name
=
"shape_tensor"
,
shape
=
[
2
],
dtype
=
"int32"
)
actual_size
=
fluid
.
data
(
name
=
"actual_size"
,
shape
=
[
2
],
dtype
=
"int32"
)
scale_tensor
=
fluid
.
data
(
name
=
"scale_tensor"
,
shape
=
[
1
],
dtype
=
"float32"
)
out1
=
fluid
.
layers
.
resize_nearest
(
y
,
out_shape
=
[
12
,
12
],
data_format
=
'NHWC'
,
align_corners
=
False
)
out2
=
fluid
.
layers
.
resize_nearest
(
x
,
out_shape
=
[
12
,
dim
],
align_corners
=
False
)
out3
=
fluid
.
layers
.
resize_nearest
(
x
,
out_shape
=
shape_tensor
,
align_corners
=
False
)
out4
=
fluid
.
layers
.
resize_nearest
(
x
,
out_shape
=
[
4
,
4
],
actual_shape
=
actual_size
,
align_corners
=
False
)
out5
=
fluid
.
layers
.
resize_nearest
(
x
,
scale
=
scale_tensor
,
align_corners
=
False
)
x_data
=
np
.
random
.
random
((
2
,
3
,
6
,
6
)).
astype
(
"float32"
)
dim_data
=
np
.
array
([
12
]).
astype
(
"int32"
)
shape_data
=
np
.
array
([
12
,
12
]).
astype
(
"int32"
)
actual_size_data
=
np
.
array
([
12
,
12
]).
astype
(
"int32"
)
scale_data
=
np
.
array
([
2.0
]).
astype
(
"float32"
)
place
=
paddle
.
MLUPlace
(
0
)
exe
=
fluid
.
Executor
(
place
)
exe
.
run
(
fluid
.
default_startup_program
())
results
=
exe
.
run
(
fluid
.
default_main_program
(),
feed
=
{
"x"
:
x_data
,
"y"
:
np
.
transpose
(
x_data
,
(
0
,
2
,
3
,
1
)),
"dim"
:
dim_data
,
"shape_tensor"
:
shape_data
,
"actual_size"
:
actual_size_data
,
"scale_tensor"
:
scale_data
},
fetch_list
=
[
out1
,
out2
,
out3
,
out4
,
out5
],
return_numpy
=
True
)
expect_res
=
nearest_neighbor_interp_np
(
x_data
,
out_h
=
12
,
out_w
=
12
,
align_corners
=
False
)
self
.
assertTrue
(
np
.
allclose
(
results
[
0
],
np
.
transpose
(
expect_res
,
(
0
,
2
,
3
,
1
))))
for
i
in
range
(
len
(
results
)
-
1
):
self
.
assertTrue
(
np
.
allclose
(
results
[
i
+
1
],
expect_res
))
class
TestNearestInterpException
(
unittest
.
TestCase
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录