forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_dimension.py
63 lines (48 loc) · 1.87 KB
/
test_dimension.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
from openvino import Dimension
def test_dynamic_dimension():
dim = Dimension()
assert dim.is_dynamic
assert str(dim) == "?"
assert dim.to_string() == "?"
assert str(dim.__repr__) == "<bound method PyCapsule.__repr__ of <Dimension: ?>>"
def test_dynamic_dimension_with_bounds():
dim = Dimension(2, 5)
assert str(dim) == "2..5"
assert dim.to_string() == "2..5"
assert not dim.is_static
assert dim.is_dynamic
assert dim.get_min_length() == 2
assert dim.min_length == 2
assert dim.get_max_length() == 5
assert dim.max_length == 5
def test_static_dimension():
dim = Dimension(2)
assert str(dim) == "2"
assert dim.to_string() == "2"
assert dim.is_static
assert not dim.is_dynamic
assert len(dim) == 2
assert dim.get_length() == 2
def test_dim_same_scheme():
assert Dimension().same_scheme(Dimension()) is True
assert Dimension(3).same_scheme(Dimension(3)) is True
assert Dimension(3).same_scheme(Dimension(4)) is False
assert Dimension().same_scheme(Dimension(4)) is False
def test_dim_compatible():
assert Dimension().compatible(Dimension()) is True
assert Dimension(3).compatible(Dimension(3)) is True
assert Dimension(3).compatible(Dimension(4)) is False
assert Dimension().compatible(Dimension(4)) is True
def test_dim_relax():
assert Dimension().relaxes(Dimension()) is True
assert Dimension(3).relaxes(Dimension(3)) is True
assert Dimension(3).relaxes(Dimension(4)) is False
assert Dimension().relaxes(Dimension(4)) is True
def test_dim_refine():
assert Dimension().refines(Dimension()) is True
assert Dimension(3).refines(Dimension(3)) is True
assert Dimension(3).refines(Dimension(4)) is False
assert Dimension().refines(Dimension(4)) is False