Refactor tests for onnx1.12
This commit is contained in:
parent
7f750a4be5
commit
e71d6c63d0
@ -22,7 +22,7 @@ ScalarData = Union[int, float]
|
||||
NodeInput = Union[Node, NumericData]
|
||||
|
||||
openvino_to_numpy_types_map = [
|
||||
(Type.boolean, np.bool),
|
||||
(Type.boolean, np.bool_),
|
||||
(Type.f16, np.float16),
|
||||
(Type.f32, np.float32),
|
||||
(Type.f64, np.float64),
|
||||
@ -38,7 +38,7 @@ openvino_to_numpy_types_map = [
|
||||
]
|
||||
|
||||
openvino_to_numpy_types_str_map = [
|
||||
("boolean", np.bool),
|
||||
("boolean", np.bool_),
|
||||
("f16", np.float16),
|
||||
("f32", np.float32),
|
||||
("f64", np.float64),
|
||||
|
@ -861,7 +861,7 @@ def test_roi_pooling():
|
||||
([2, 3, 5, 6], [7, 4], [7], 2, 2, 1, 1.0, "avg", "asymmetric", [7, 3, 2, 2]),
|
||||
([10, 3, 5, 5], [7, 4], [7], 3, 4, 1, 1.0, "avg", "half_pixel_for_nn", [7, 3, 3, 4]),
|
||||
([10, 3, 5, 5], [3, 4], [3], 3, 4, 1, 1.0, "avg", "half_pixel", [3, 3, 3, 4]),
|
||||
([10, 3, 5, 5], [3, 4], [3], 3, 4, 1, np.float(1), "avg", "half_pixel", [3, 3, 3, 4]),
|
||||
([10, 3, 5, 5], [3, 4], [3], 3, 4, 1, np.float64(1), "avg", "half_pixel", [3, 3, 3, 4]),
|
||||
],
|
||||
)
|
||||
def test_roi_align(data_shape, rois, batch_indices, pooled_h, pooled_w, sampling_ratio, spatial_scale, mode, aligned_mode, expected_shape):
|
||||
|
@ -12,9 +12,9 @@ from tests.test_onnx.utils import run_node
|
||||
@pytest.mark.parametrize(
|
||||
("onnx_op", "numpy_func", "data_type"),
|
||||
[
|
||||
pytest.param("And", np.logical_and, np.bool),
|
||||
pytest.param("Or", np.logical_or, np.bool),
|
||||
pytest.param("Xor", np.logical_xor, np.bool),
|
||||
pytest.param("And", np.logical_and, np.bool_),
|
||||
pytest.param("Or", np.logical_or, np.bool_),
|
||||
pytest.param("Xor", np.logical_xor, np.bool_),
|
||||
pytest.param("Equal", np.equal, np.int32),
|
||||
pytest.param("Greater", np.greater, np.int32),
|
||||
pytest.param("Less", np.less, np.int32),
|
||||
|
@ -6,6 +6,7 @@ import numpy as np
|
||||
import onnx
|
||||
import onnx.backend.test
|
||||
import unittest
|
||||
import dataclasses
|
||||
|
||||
from collections import defaultdict, namedtuple
|
||||
from onnx import numpy_helper, NodeProto, ModelProto
|
||||
@ -28,9 +29,13 @@ from typing import (
|
||||
Sequence,
|
||||
)
|
||||
|
||||
if getattr(OnnxTestCase, '_fields', None):
|
||||
ExtOnnxTestCase = OnnxTestCase._fields + ("post_processing",)
|
||||
else: # for ONNX >= 1.12
|
||||
ExtOnnxTestCase = tuple((field.name for field in dataclasses.fields(OnnxTestCase))) + ("post_processing",)
|
||||
|
||||
# add post-processing function as part of test data
|
||||
ExtOnnxTestCase = namedtuple("TestCaseExt", OnnxTestCase._fields + ("post_processing",))
|
||||
#ExtOnnxTestCase = namedtuple("TestCaseExt", OnnxTestCase_fields + ("post_processing",))
|
||||
#ExtOnnxTestCase = namedtuple("TestCaseExt", OnnxTestCase_fields + ("post_processing",))
|
||||
|
||||
|
||||
class ModelImportRunner(onnx.backend.test.BackendTest):
|
||||
|
@ -376,7 +376,7 @@ def test_infer_mixed_keys(device):
|
||||
(Type.u16, np.uint16),
|
||||
(Type.i64, np.int64),
|
||||
(Type.u64, np.uint64),
|
||||
(Type.boolean, np.bool),
|
||||
(Type.boolean, np.bool_),
|
||||
])
|
||||
def test_infer_mixed_values(device, ov_type, numpy_dtype):
|
||||
request, tensor1, array1 = concat_model_with_data(device, ov_type, numpy_dtype)
|
||||
@ -399,7 +399,7 @@ def test_infer_mixed_values(device, ov_type, numpy_dtype):
|
||||
(Type.u16, np.uint16),
|
||||
(Type.i64, np.int64),
|
||||
(Type.u64, np.uint64),
|
||||
(Type.boolean, np.bool),
|
||||
(Type.boolean, np.bool_),
|
||||
])
|
||||
def test_async_mixed_values(device, ov_type, numpy_dtype):
|
||||
request, tensor1, array1 = concat_model_with_data(device, ov_type, numpy_dtype)
|
||||
|
@ -30,7 +30,7 @@ from ..test_utils.test_utils import generate_image # TODO: reformat into an abs
|
||||
(ov.Type.u16, np.uint16),
|
||||
(ov.Type.i64, np.int64),
|
||||
(ov.Type.u64, np.uint64),
|
||||
(ov.Type.boolean, np.bool),
|
||||
(ov.Type.boolean, np.bool_),
|
||||
(ov.Type.u1, np.uint8),
|
||||
(ov.Type.u4, np.uint8),
|
||||
(ov.Type.i4, np.int8),
|
||||
@ -64,7 +64,7 @@ def test_subprocess():
|
||||
(ov.Type.u16, np.uint16),
|
||||
(ov.Type.i64, np.int64),
|
||||
(ov.Type.u64, np.uint64),
|
||||
(ov.Type.boolean, np.bool),
|
||||
(ov.Type.boolean, np.bool_),
|
||||
])
|
||||
def test_init_with_numpy_dtype(ov_type, numpy_dtype):
|
||||
shape = (1, 3, 127, 127)
|
||||
@ -94,7 +94,7 @@ def test_init_with_numpy_dtype(ov_type, numpy_dtype):
|
||||
(ov.Type.u16, np.uint16),
|
||||
(ov.Type.i64, np.int64),
|
||||
(ov.Type.u64, np.uint64),
|
||||
(ov.Type.boolean, np.bool),
|
||||
(ov.Type.boolean, np.bool_),
|
||||
])
|
||||
def test_init_with_numpy_shared_memory(ov_type, numpy_dtype):
|
||||
arr = generate_image().astype(numpy_dtype)
|
||||
@ -131,7 +131,7 @@ def test_init_with_numpy_shared_memory(ov_type, numpy_dtype):
|
||||
(ov.Type.u16, np.uint16),
|
||||
(ov.Type.i64, np.int64),
|
||||
(ov.Type.u64, np.uint64),
|
||||
(ov.Type.boolean, np.bool),
|
||||
(ov.Type.boolean, np.bool_),
|
||||
])
|
||||
def test_init_with_numpy_copy_memory(ov_type, numpy_dtype):
|
||||
arr = generate_image().astype(numpy_dtype)
|
||||
@ -178,7 +178,7 @@ def test_init_with_roi_tensor():
|
||||
(ov.Type.u16, np.uint16),
|
||||
(ov.Type.i64, np.int64),
|
||||
(ov.Type.u64, np.uint64),
|
||||
(ov.Type.boolean, np.bool),
|
||||
(ov.Type.boolean, np.bool_),
|
||||
])
|
||||
def test_write_to_buffer(ov_type, numpy_dtype):
|
||||
ov_tensor = Tensor(ov_type, ov.Shape([1, 3, 32, 32]))
|
||||
@ -200,7 +200,7 @@ def test_write_to_buffer(ov_type, numpy_dtype):
|
||||
(ov.Type.u16, np.uint16),
|
||||
(ov.Type.i64, np.int64),
|
||||
(ov.Type.u64, np.uint64),
|
||||
(ov.Type.boolean, np.bool),
|
||||
(ov.Type.boolean, np.bool_),
|
||||
])
|
||||
def test_set_shape(ov_type, numpy_dtype):
|
||||
shape = ov.Shape([1, 3, 32, 32])
|
||||
|
Loading…
Reference in New Issue
Block a user