From eb443808b92138864fde5720038fc5e65ff10a10 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Tue, 20 Feb 2024 20:06:03 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=8D=95=E6=B5=8Bonnxruntime=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=9B=B4=E6=96=B0=E5=88=B0=E6=9C=80=E6=96=B0=E7=9A=84?= =?UTF-8?q?onnxruntime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index 6b3f65b3d..8bbff367e 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -67,7 +67,7 @@ bug=0 export PY_CMD=$1 $PY_CMD -m pip install pytest $PY_CMD -m pip uninstall onnxruntime -$PY_CMD -m pip install onnxruntime==1.11.1 +$PY_CMD -m pip install onnxruntime export ENABLE_DEV=ON echo "============ failed cases =============" >> result.txt for file in ${cases} From 08866fd3ec7a989bda5cf7bb2da85f033782b616 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Tue, 20 Feb 2024 20:19:10 +0800 Subject: [PATCH 02/13] Pad should be smaller than kernel. --- tests/test_nn_MaxPool2D.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tests/test_nn_MaxPool2D.py b/tests/test_nn_MaxPool2D.py index 84178f906..51b6b52d6 100644 --- a/tests/test_nn_MaxPool2D.py +++ b/tests/test_nn_MaxPool2D.py @@ -158,30 +158,3 @@ def test_MaxPool2D_base_Padding_3(): paddle.to_tensor( randtool("float", -1, 1, [3, 1, 10, 10]).astype('float32'))) obj.run() - - -def test_MaxPool2D_base_Padding_4(): - """ - api: paddle.MaxPool2D - op version: 9, 10, 11, 12 - """ - op = Net(kernel_size=5, padding=[1, 2, 3, 5]) - op.eval() - # net, name, ver_list, delta=1e-6, rtol=1e-5 - obj = APIOnnx(op, 'nn_MaxPool2D', [9, 10, 11, 12]) - obj.set_input_data( - "input_data", - paddle.to_tensor( - randtool("float", -1, 1, [3, 1, 10, 10]).astype('float32'))) - obj.run() - - -# if __name__ == '__main__': -# test_MaxPool2D_base() -# test_MaxPool2D_base_SAME() -# test_MaxPool2D_base_VALID() -# test_MaxPool2D_base_Padding_4() -# test_MaxPool2D_base_Padding_3() -# test_MaxPool2D_base_Padding_2() -# test_MaxPool2D_base_Padding_1() -# test_MaxPool2D_base_Padding_0() From 3e922f57fb8e9ac4a4e80a472ef423113c524cea Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 09:15:30 +0800 Subject: [PATCH 03/13] update ci run.sh --- tests/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 8bbff367e..0a1d28c12 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -65,9 +65,9 @@ ignore="test_auto_scan_roi_align.py \ # need to be rewrite test_quantize_model_speedup.py" bug=0 export PY_CMD=$1 -$PY_CMD -m pip install pytest -$PY_CMD -m pip uninstall onnxruntime -$PY_CMD -m pip install onnxruntime +$PY_CMD -m pip install -y pytest +$PY_CMD -m pip uninstall -y onnxruntime +$PY_CMD -m pip install -y onnxruntime export ENABLE_DEV=ON echo "============ failed cases =============" >> result.txt for file in ${cases} From 6c4a6c3af623d12a2ee1acf75ff3ddaa4f0b9675 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 09:20:50 +0800 Subject: [PATCH 04/13] axis must be a list --- tests/test_auto_scan_squeeze2.py | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/tests/test_auto_scan_squeeze2.py b/tests/test_auto_scan_squeeze2.py index 2d3b0eba4..bc087d474 100755 --- a/tests/test_auto_scan_squeeze2.py +++ b/tests/test_auto_scan_squeeze2.py @@ -52,29 +52,15 @@ def sample_convert_config(self, draw): st.integers( min_value=4, max_value=10), min_size=3, max_size=5)) - dtype = draw( - st.sampled_from(["bool", "float32", "float64", "int32", "int64"])) - axis = None - axis_dtype = draw(st.sampled_from(["None", "int", "list"])) - if axis_dtype == "list": - axis = draw( - st.integers( - min_value=-len(input_shape), max_value=len(input_shape) - - 1)) - if axis == 0: - axis = [0, -1] - else: - axis = [0, axis] - input_shape[axis[0]] = 1 - input_shape[axis[1]] = 1 - elif axis_dtype == "int": - axis = draw( - st.integers( - min_value=-len(input_shape), max_value=len(input_shape) - - 1)) - input_shape[axis] = 1 + dtype = draw(st.sampled_from(["bool", "float32", "float64", "int32", "int64"])) + + axis = draw(st.integers(min_value=-len(input_shape), max_value=len(input_shape) - 1)) + if axis == 0: + axis = [0, -1] else: - input_shape[0] = 1 + axis = [0, axis] + input_shape[axis[0]] = 1 + input_shape[axis[1]] = 1 tensor_attr = draw(st.booleans()) From 9f3770c5982117cd37184d8722e3aa5920f57900 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 09:23:02 +0800 Subject: [PATCH 05/13] restart test_split.py/test_expand_as.py in CI --- tests/run.sh | 2 - tests/test_split.py | 116 ++++++++++++++++++++++---------------------- 2 files changed, 58 insertions(+), 60 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index 0a1d28c12..0b86759bf 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -26,8 +26,6 @@ cases=$(find . -name "test*.py" | sort) ignore="test_auto_scan_roi_align.py \ # need to be rewrite - test_expand_as.py \ - test_split.py \ test_auto_scan_pool_adaptive_max_ops.py \ test_auto_scan_interpolate_v1_ops.py \ test_auto_scan_isx_ops.py \ diff --git a/tests/test_split.py b/tests/test_split.py index 6aabe9a77..e125d5dd9 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -33,61 +33,61 @@ def forward(self, inputs): return x -# def test_split_9(): -# """ -# api: paddle.split -# op version: 9 -# """ -# op = Net() -# op.eval() -# # net, name, ver_list, delta=1e-6, rtol=1e-5 -# obj = APIOnnx(op, 'split', [9]) -# obj.set_input_data("input_data", -# paddle.to_tensor( -# randtool("float", -1, 1, [3, 10]).astype('float32'))) -# obj.run() -# -# -# def test_split_10(): -# """ -# api: paddle.split -# op version: 10 -# """ -# op = Net() -# op.eval() -# # net, name, ver_list, delta=1e-6, rtol=1e-5 -# obj = APIOnnx(op, 'split', [10]) -# obj.set_input_data("input_data", -# paddle.to_tensor( -# randtool("float", -1, 1, [3, 10]).astype('float32'))) -# obj.run() -# -# -# def test_split_11(): -# """ -# api: paddle.split -# op version: 11 -# """ -# op = Net() -# op.eval() -# # net, name, ver_list, delta=1e-6, rtol=1e-5 -# obj = APIOnnx(op, 'split', [11]) -# obj.set_input_data("input_data", -# paddle.to_tensor( -# randtool("float", -1, 1, [3, 10]).astype('float32'))) -# obj.run() -# -# -# def test_split_12(): -# """ -# api: paddle.split -# op version: 12 -# """ -# op = Net() -# op.eval() -# # net, name, ver_list, delta=1e-6, rtol=1e-5 -# obj = APIOnnx(op, 'split', [12]) -# obj.set_input_data("input_data", -# paddle.to_tensor( -# randtool("float", -1, 1, [3, 10]).astype('float32'))) -# obj.run() +def test_split_9(): + """ + api: paddle.split + op version: 9 + """ + op = Net() + op.eval() + # net, name, ver_list, delta=1e-6, rtol=1e-5 + obj = APIOnnx(op, 'split', [9]) + obj.set_input_data("input_data", + paddle.to_tensor( + randtool("float", -1, 1, [3, 10]).astype('float32'))) + obj.run() + + +def test_split_10(): + """ + api: paddle.split + op version: 10 + """ + op = Net() + op.eval() + # net, name, ver_list, delta=1e-6, rtol=1e-5 + obj = APIOnnx(op, 'split', [10]) + obj.set_input_data("input_data", + paddle.to_tensor( + randtool("float", -1, 1, [3, 10]).astype('float32'))) + obj.run() + + +def test_split_11(): + """ + api: paddle.split + op version: 11 + """ + op = Net() + op.eval() + # net, name, ver_list, delta=1e-6, rtol=1e-5 + obj = APIOnnx(op, 'split', [11]) + obj.set_input_data("input_data", + paddle.to_tensor( + randtool("float", -1, 1, [3, 10]).astype('float32'))) + obj.run() + + +def test_split_12(): + """ + api: paddle.split + op version: 12 + """ + op = Net() + op.eval() + # net, name, ver_list, delta=1e-6, rtol=1e-5 + obj = APIOnnx(op, 'split', [12]) + obj.set_input_data("input_data", + paddle.to_tensor( + randtool("float", -1, 1, [3, 10]).astype('float32'))) + obj.run() From d70cea70569799f4b869540061818775aae06712 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 09:24:58 +0800 Subject: [PATCH 06/13] * paddle.fluid.layers.topk has been abandoned, remove it on CI * rename topk_v2 to topk --- tests/run.sh | 1 - tests/test_auto_scan_top_k.py | 116 +++++++++++++++---------------- tests/test_auto_scan_top_k_v2.py | 115 ------------------------------ 3 files changed, 56 insertions(+), 176 deletions(-) mode change 100644 => 100755 tests/test_auto_scan_top_k.py delete mode 100755 tests/test_auto_scan_top_k_v2.py diff --git a/tests/run.sh b/tests/run.sh index 0b86759bf..a262eb05c 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -33,7 +33,6 @@ ignore="test_auto_scan_roi_align.py \ # need to be rewrite test_auto_scan_pad2d.py \ test_auto_scan_roll.py \ test_auto_scan_set_value.py \ - test_auto_scan_top_k.py \ test_auto_scan_unfold.py \ test_auto_scan_uniform_random_batch_size_like.py \ test_auto_scan_uniform_random.py \ diff --git a/tests/test_auto_scan_top_k.py b/tests/test_auto_scan_top_k.py old mode 100644 new mode 100755 index 7f72f43bc..176965d41 --- a/tests/test_auto_scan_top_k.py +++ b/tests/test_auto_scan_top_k.py @@ -19,6 +19,7 @@ import unittest import paddle import random +from random import shuffle class Net(BaseNet): @@ -26,66 +27,25 @@ class Net(BaseNet): simple Net """ - def forward(self, input, k): - """ - forward - """ - x = paddle.fluid.layers.topk(input, k=k) - return x - - -class TestTopkConvert(OPConvertAutoScanTest): - """ - api: paddle.fluid.layers.topk - OPset version: 11, 15 - """ - - def sample_convert_config(self, draw): - input_shape = draw( - st.lists( - st.integers( - min_value=4, max_value=10), min_size=1, max_size=5)) - - dtype = draw(st.sampled_from(["float32", "float64"])) - k = random.randint(1, min(input_shape)) - isTensor = draw(st.booleans()) - - def generator_k(): - input_data = np.array([k]) - return input_data - - config = { - "op_names": ["top_k"], - "test_data_shapes": [input_shape, generator_k], - "test_data_types": [[dtype], ["int32"]], - "opset_version": [11, 15], - "input_spec_shape": [], - } - - models = Net(config) - - return (config, models) - - def test(self): - self.run_and_statis(max_examples=30) - - -class Net1(BaseNet): - """ - simple Net - """ - def forward(self, input): """ forward """ - x = paddle.fluid.layers.topk(input, k=self.config['k']) + k = self.config['k'] + if self.config['isTensor']: + k = paddle.to_tensor(k, dtype=self.config['k_dtype']) + x = paddle.topk( + input, + k=k, + axis=self.config['axis'], + largest=self.config['largest'], + sorted=self.config['sorted']) return x -class TestTopkConvert1(OPConvertAutoScanTest): +class TestTopkv2Convert(OPConvertAutoScanTest): """ - api: paddle.fluid.layers.topk + api: paddle.topk OPset version: 11, 15 """ @@ -93,26 +53,62 @@ def sample_convert_config(self, draw): input_shape = draw( st.lists( st.integers( - min_value=4, max_value=10), min_size=1, max_size=5)) + min_value=1, max_value=3), min_size=0, max_size=5)) + axis = None + if draw(st.booleans()) and len(input_shape) > 0: + axis = draw( + st.integers( + min_value=-len(input_shape), max_value=len(input_shape) - + 1)) + + dtype = draw(st.sampled_from(["float32", "float64", "int32", "int64"])) + k_dtype = draw(st.sampled_from(["int32", "int64"])) + largest = draw(st.booleans()) + # has a diff when sorted is False + sorted = draw(st.booleans()) + + def generator_data(): + if len(input_shape) == 0: + return np.array(10, dtype="float32") + prod = np.prod(input_shape) + input_data = np.array(list(range(0, prod))) + shuffle(input_data) + input_data = input_data.reshape(input_shape) + return input_data - dtype = draw(st.sampled_from(["float32", "float64"])) - k = random.randint(1, min(input_shape)) + if len(input_shape) > 0: + if axis is not None: + k = random.randint(1, input_shape[axis]) + else: + k = random.randint(1, input_shape[-1]) + else: + k = 1 + axis = 0 + isTensor = draw(st.booleans()) config = { - "op_names": ["top_k"], - "test_data_shapes": [input_shape], + "op_names": ["top_k_v2"], + "test_data_shapes": [generator_data], "test_data_types": [[dtype]], - "opset_version": [11, 15], + "opset_version": [11, 12, 13, 14, 15], "input_spec_shape": [], + "axis": axis, + "largest": largest, + "sorted": sorted, + "isTensor": isTensor, "k": k, + "k_dtype": k_dtype, + "rtol": 200, + "delta": 200, + "input_shape": input_shape } - models = Net1(config) + models = Net(config) return (config, models) def test(self): - self.run_and_statis(max_examples=30) + self.run_and_statis(max_examples=80) if __name__ == "__main__": diff --git a/tests/test_auto_scan_top_k_v2.py b/tests/test_auto_scan_top_k_v2.py deleted file mode 100755 index 176965d41..000000000 --- a/tests/test_auto_scan_top_k_v2.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License" -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from auto_scan_test import OPConvertAutoScanTest, BaseNet -from hypothesis import reproduce_failure -import hypothesis.strategies as st -import numpy as np -import unittest -import paddle -import random -from random import shuffle - - -class Net(BaseNet): - """ - simple Net - """ - - def forward(self, input): - """ - forward - """ - k = self.config['k'] - if self.config['isTensor']: - k = paddle.to_tensor(k, dtype=self.config['k_dtype']) - x = paddle.topk( - input, - k=k, - axis=self.config['axis'], - largest=self.config['largest'], - sorted=self.config['sorted']) - return x - - -class TestTopkv2Convert(OPConvertAutoScanTest): - """ - api: paddle.topk - OPset version: 11, 15 - """ - - def sample_convert_config(self, draw): - input_shape = draw( - st.lists( - st.integers( - min_value=1, max_value=3), min_size=0, max_size=5)) - axis = None - if draw(st.booleans()) and len(input_shape) > 0: - axis = draw( - st.integers( - min_value=-len(input_shape), max_value=len(input_shape) - - 1)) - - dtype = draw(st.sampled_from(["float32", "float64", "int32", "int64"])) - k_dtype = draw(st.sampled_from(["int32", "int64"])) - largest = draw(st.booleans()) - # has a diff when sorted is False - sorted = draw(st.booleans()) - - def generator_data(): - if len(input_shape) == 0: - return np.array(10, dtype="float32") - prod = np.prod(input_shape) - input_data = np.array(list(range(0, prod))) - shuffle(input_data) - input_data = input_data.reshape(input_shape) - return input_data - - if len(input_shape) > 0: - if axis is not None: - k = random.randint(1, input_shape[axis]) - else: - k = random.randint(1, input_shape[-1]) - else: - k = 1 - axis = 0 - isTensor = draw(st.booleans()) - - config = { - "op_names": ["top_k_v2"], - "test_data_shapes": [generator_data], - "test_data_types": [[dtype]], - "opset_version": [11, 12, 13, 14, 15], - "input_spec_shape": [], - "axis": axis, - "largest": largest, - "sorted": sorted, - "isTensor": isTensor, - "k": k, - "k_dtype": k_dtype, - "rtol": 200, - "delta": 200, - "input_shape": input_shape - } - - models = Net(config) - - return (config, models) - - def test(self): - self.run_and_statis(max_examples=80) - - -if __name__ == "__main__": - unittest.main() From c6adc540d3ed62a4dabde3d710062eb72209f715 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 09:33:16 +0800 Subject: [PATCH 07/13] paddle.fluid.layers.image_resize has been abandoned, remove it on CI --- tests/run.sh | 1 - tests/test_auto_scan_interpolate_v1_ops.py | 301 --------------------- 2 files changed, 302 deletions(-) delete mode 100755 tests/test_auto_scan_interpolate_v1_ops.py diff --git a/tests/run.sh b/tests/run.sh index a262eb05c..e738e12dc 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -27,7 +27,6 @@ cases=$(find . -name "test*.py" | sort) ignore="test_auto_scan_roi_align.py \ # need to be rewrite test_auto_scan_pool_adaptive_max_ops.py \ - test_auto_scan_interpolate_v1_ops.py \ test_auto_scan_isx_ops.py \ test_auto_scan_masked_select.py \ test_auto_scan_pad2d.py \ diff --git a/tests/test_auto_scan_interpolate_v1_ops.py b/tests/test_auto_scan_interpolate_v1_ops.py deleted file mode 100755 index 2c65391bc..000000000 --- a/tests/test_auto_scan_interpolate_v1_ops.py +++ /dev/null @@ -1,301 +0,0 @@ -# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License" -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from auto_scan_test import OPConvertAutoScanTest, BaseNet -from hypothesis import reproduce_failure -import hypothesis.strategies as st -import numpy as np -import unittest -import paddle - -op_api_map = { - 'LINEAR': 'linear_interp', - 'NEAREST': 'nearest_interp', - 'BILINEAR': 'bilinear_interp', - 'TRILINEAR': 'trilinear_interp', -} - -data_format_map = { - 'LINEAR': 'NCW', - 'NEAREST': 'NCHW', - 'BILINEAR': 'NCHW', - 'TRILINEAR': 'NCDHW', -} - -op_set_map = { - 'LINEAR': [9, 10, 11, 12, 13, 14, 15], - 'NEAREST': [9, 10, 11, 12, 13, 14, 15], - 'BILINEAR': [9, 10, 11, 12, 13, 14, 15], - 'TRILINEAR': [9, 10, 11, 12, 13, 14, 15] -} - - -class Net2(BaseNet): - """ - simple Net - """ - - def forward(self, inputs): - """ - forward - """ - scale = self.config['scale_factor'] - if self.config['is_scale_tensor'] and scale is not None: - scale = paddle.to_tensor(scale, dtype=self.config['scale_dtype']) - - out_shape = self.config['size'] - if self.config['is_size_tensor'] and out_shape is not None: - out_shape = paddle.to_tensor(out_shape, self.config['size_dtype']) - - align_corners = self.config['align_corners'] - align_mode = self.config['align_mode'] - data_format = self.config['data_format'] - mode = self.config['mode'] - - x = paddle.fluid.layers.image_resize( - inputs, - out_shape=out_shape, - scale=scale, - resample=mode, - align_corners=align_corners, - align_mode=align_mode, - data_format=data_format) - return x - - -class TestInterpolateConvert2(OPConvertAutoScanTest): - """ - api: paddle.nn.functional.interpolate - OPset version: 9, 11, 15 - """ - - def sample_convert_config(self, draw): - input_shape = draw( - st.lists( - st.integers( - min_value=2, max_value=8), min_size=5, max_size=6)) - - dtype = draw(st.sampled_from(["float32"])) - # mode = draw(st.sampled_from(["LINEAR"])) - # mode = draw(st.sampled_from(["NEAREST"])) - # mode = draw(st.sampled_from(["BILINEAR"])) - # mode = draw(st.sampled_from(["TRILINEAR"])) - mode = draw( - st.sampled_from(["LINEAR", "NEAREST", "BILINEAR", "TRILINEAR"])) - align_corners = draw(st.booleans()) - align_mode = draw(st.integers(min_value=0, max_value=1)) - data_format = data_format_map[mode] - if data_format == "NCW": - input_shape = np.random.choice(input_shape, 3) - input_shape[0] = 1 # there is a bug when index > 1 - elif data_format == "NCHW": - input_shape = np.random.choice(input_shape, 4) - else: - input_shape = np.random.choice(input_shape, 5) - - size_dtype = draw(st.sampled_from(["int32"])) - scale_dtype = draw(st.sampled_from(["float32"])) - - is_scale_tensor = False - is_size_tensor = False - if draw(st.booleans()): - size = None - # scale_factor should b even. eg [2, 4, 6, 8, 10] - is_scale_tensor = draw(st.booleans()) - scale_factor = draw(st.integers(min_value=2, max_value=10)) - scale_factor = scale_factor + 1 if scale_factor % 2 != 0 else scale_factor - else: - scale_factor = None - is_size_tensor = draw(st.booleans()) - size1 = draw(st.integers(min_value=12, max_value=30)) - size2 = draw(st.integers(min_value=12, max_value=30)) - size3 = draw(st.integers(min_value=12, max_value=30)) - if mode == 'LINEAR': - size = [size1] - if mode in ['NEAREST', 'BILINEAR']: - # NEAREST, size should be even - if mode == 'NEAREST': - size1 = size1 + 1 if size1 % 2 != 0 else size1 - size2 = size2 + 1 if size2 % 2 != 0 else size2 - size = [size1, size2] - if mode == "TRILINEAR": - size = [size1, size2, size3] - - op_name = op_api_map[mode] - opset_version = op_set_map[mode] - - if align_mode == 0 and mode in ["LINEAR", "BILINEAR", "TRILINEAR"]: - opset_version = [11, 12, 13, 14, 15] - - if align_corners: - opset_version = [11, 12, 13, 14, 15] - - config = { - "op_names": [op_name], - "test_data_shapes": [input_shape], - "test_data_types": [[dtype]], - "opset_version": opset_version, - "input_spec_shape": [], - "size": size, - "scale_factor": scale_factor, - "mode": mode, - "align_corners": align_corners, - "align_mode": align_mode, - "data_format": data_format, - "is_scale_tensor": is_scale_tensor, - "is_size_tensor": is_size_tensor, - "size_dtype": size_dtype, - "scale_dtype": scale_dtype, - } - - models = Net2(config) - - return (config, models) - - def test(self): - self.run_and_statis(max_examples=80) - - -class Net3(BaseNet): - """ - simple Net - """ - - def forward(self, inputs): - """ - forward - """ - scale = None - out_shape = self.config['size'] - mode = self.config['mode'] - - if mode == "LINEAR": - out_shape = [paddle.to_tensor(12, self.config['size_dtype'])] - elif mode in ["NEAREST", "BILINEAR"]: - out_shape = [paddle.to_tensor(12, self.config['size_dtype']), 14] - elif mode == "TRILINEAR": - out_shape = [ - paddle.to_tensor(12, self.config['size_dtype']), 13, 14 - ] - - align_corners = self.config['align_corners'] - align_mode = self.config['align_mode'] - data_format = self.config['data_format'] - - x = paddle.fluid.layers.image_resize( - inputs, - out_shape=out_shape, - scale=scale, - resample=mode, - align_corners=align_corners, - align_mode=align_mode, - data_format=data_format) - return x - - -class TestInterpolateConvert3(OPConvertAutoScanTest): - """ - api: paddle.nn.functional.interpolate - OPset version: 9, 11, 15 - """ - - def sample_convert_config(self, draw): - input_shape = draw( - st.lists( - st.integers( - min_value=2, max_value=8), min_size=5, max_size=6)) - - dtype = draw(st.sampled_from(["float32"])) - # mode = draw(st.sampled_from(["LINEAR"])) - # mode = draw(st.sampled_from(["NEAREST"])) - # mode = draw(st.sampled_from(["BILINEAR"])) - # mode = draw(st.sampled_from(["TRILINEAR"])) - mode = draw( - st.sampled_from(["LINEAR", "NEAREST", "BILINEAR", "TRILINEAR"])) - align_corners = draw(st.booleans()) - align_mode = draw(st.integers(min_value=0, max_value=1)) - data_format = data_format_map[mode] - if data_format == "NCW": - input_shape = np.random.choice(input_shape, 3) - input_shape[0] = 1 # there is a bug when index > 1 - elif data_format == "NCHW": - input_shape = np.random.choice(input_shape, 4) - else: - input_shape = np.random.choice(input_shape, 5) - - size_dtype = draw(st.sampled_from(["int32"])) - scale_dtype = draw(st.sampled_from(["float32"])) - - is_scale_tensor = False - is_size_tensor = False - if draw(st.booleans()): - size = None - # scale_factor should b even. eg [2, 4, 6, 8, 10] - is_scale_tensor = draw(st.booleans()) - scale_factor = draw(st.integers(min_value=2, max_value=10)) - scale_factor = scale_factor + 1 if scale_factor % 2 != 0 else scale_factor - else: - scale_factor = None - is_size_tensor = draw(st.booleans()) - size1 = draw(st.integers(min_value=12, max_value=30)) - size2 = draw(st.integers(min_value=12, max_value=30)) - size3 = draw(st.integers(min_value=12, max_value=30)) - if mode == 'LINEAR': - size = [size1] - if mode in ['NEAREST', 'BILINEAR']: - # NEAREST, size should be even - if mode == 'NEAREST': - size1 = size1 + 1 if size1 % 2 != 0 else size1 - size2 = size2 + 1 if size2 % 2 != 0 else size2 - size = [size1, size2] - if mode == "TRILINEAR": - size = [size1, size2, size3] - - op_name = op_api_map[mode] - opset_version = op_set_map[mode] - - if align_mode == 0 and mode in ["LINEAR", "BILINEAR", "TRILINEAR"]: - opset_version = [11, 12, 13, 14, 15] - - if align_corners: - opset_version = [11, 12, 13, 14, 15] - - config = { - "op_names": [op_name], - "test_data_shapes": [input_shape], - "test_data_types": [[dtype]], - "opset_version": opset_version, - "input_spec_shape": [], - "size": size, - "scale_factor": scale_factor, - "mode": mode, - "align_corners": align_corners, - "align_mode": align_mode, - "data_format": data_format, - "is_scale_tensor": is_scale_tensor, - "is_size_tensor": is_size_tensor, - "size_dtype": size_dtype, - "scale_dtype": scale_dtype, - } - - models = Net3(config) - - return (config, models) - - def test(self): - self.run_and_statis(max_examples=80) - - -if __name__ == "__main__": - unittest.main() From c5d5fa1b2a90bdea65b121a2fd49ef8360a903e6 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 09:37:21 +0800 Subject: [PATCH 08/13] paddle.base.layers.has_nan has been abandoned, remove it on CI --- tests/test_auto_scan_isx_ops.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 tests/test_auto_scan_isx_ops.py diff --git a/tests/test_auto_scan_isx_ops.py b/tests/test_auto_scan_isx_ops.py old mode 100755 new mode 100644 From b0bd969438f892649ff553c6af6beb8f31fdc374 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 12:18:08 +0800 Subject: [PATCH 09/13] support install newest onnxruntime --- tests/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.sh b/tests/run.sh index e738e12dc..df4efdd2f 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -63,7 +63,7 @@ bug=0 export PY_CMD=$1 $PY_CMD -m pip install -y pytest $PY_CMD -m pip uninstall -y onnxruntime -$PY_CMD -m pip install -y onnxruntime +$PY_CMD -m pip install onnxruntime export ENABLE_DEV=ON echo "============ failed cases =============" >> result.txt for file in ${cases} From f5e9437d56599c7bdbd822fe8784c5dd5731d90d Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Wed, 21 Feb 2024 14:43:31 +0800 Subject: [PATCH 10/13] bind ci to paddlepaddle2.6.0 --- tests/run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/run.sh b/tests/run.sh index df4efdd2f..fa39208b1 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -64,6 +64,8 @@ export PY_CMD=$1 $PY_CMD -m pip install -y pytest $PY_CMD -m pip uninstall -y onnxruntime $PY_CMD -m pip install onnxruntime +$PY_CMD -m pip uninstall -y paddlepaddle-gpu +$PY_CMD -m pip install paddlepaddle-gpu==2.6.0 export ENABLE_DEV=ON echo "============ failed cases =============" >> result.txt for file in ${cases} From 01d2c3c8eed28873a4edc90f0641895ea5973019 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Thu, 22 Feb 2024 08:56:47 +0800 Subject: [PATCH 11/13] bind ci to paddlepaddle2.6.0 --- tests/run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index fa39208b1..fd9ff9062 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -61,11 +61,11 @@ ignore="test_auto_scan_roi_align.py \ # need to be rewrite test_quantize_model_speedup.py" bug=0 export PY_CMD=$1 -$PY_CMD -m pip install -y pytest +$PY_CMD -m pip install -y pytest -i https://pypi.tuna.tsinghua.edu.cn/simple $PY_CMD -m pip uninstall -y onnxruntime -$PY_CMD -m pip install onnxruntime +$PY_CMD -m pip install onnxruntime -i https://pypi.tuna.tsinghua.edu.cn/simple $PY_CMD -m pip uninstall -y paddlepaddle-gpu -$PY_CMD -m pip install paddlepaddle-gpu==2.6.0 +$PY_CMD -m pip install paddlepaddle==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple export ENABLE_DEV=ON echo "============ failed cases =============" >> result.txt for file in ${cases} From f18a6f22953ceb17a6ec2a869c499e6b38012d1e Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Fri, 23 Feb 2024 19:09:14 +0800 Subject: [PATCH 12/13] update run.sh --- tests/run.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/run.sh b/tests/run.sh index fd9ff9062..3d0a91284 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -60,12 +60,15 @@ ignore="test_auto_scan_roi_align.py \ # need to be rewrite test_quantize_model_minist.py \ test_quantize_model_speedup.py" bug=0 + +# Install Python Packet export PY_CMD=$1 -$PY_CMD -m pip install -y pytest -i https://pypi.tuna.tsinghua.edu.cn/simple -$PY_CMD -m pip uninstall -y onnxruntime -$PY_CMD -m pip install onnxruntime -i https://pypi.tuna.tsinghua.edu.cn/simple -$PY_CMD -m pip uninstall -y paddlepaddle-gpu +$PY_CMD -m pip install pytest -i https://pypi.tuna.tsinghua.edu.cn/simple +$PY_CMD -m pip install onnx onnxruntime tqdm filelock -i https://pypi.tuna.tsinghua.edu.cn/simple $PY_CMD -m pip install paddlepaddle==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple +$PY_CMD -m pip install six hypothesis -i https://pypi.tuna.tsinghua.edu.cn/simple + + export ENABLE_DEV=ON echo "============ failed cases =============" >> result.txt for file in ${cases} From 488bcfecdb7e049b4e03659b9fa5037a7a6602b5 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng Date: Mon, 26 Feb 2024 10:06:25 +0800 Subject: [PATCH 13/13] remove requirement.txt in test --- tests/requirements.txt | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tests/requirements.txt diff --git a/tests/requirements.txt b/tests/requirements.txt deleted file mode 100644 index 24ef3c790..000000000 --- a/tests/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -onnx==1.13.0 -onnxruntime==1.16.0 -hypothesis -paddleslim