3
3
4
4
import numpy as np
5
5
import pytest
6
+ import platform
6
7
7
8
from common .tf_layer_test_class import CommonTFLayerTest
8
- from common .utils .tf_utils import permute_nchw_to_nhwc
9
9
10
+ rng = np .random .default_rng ()
11
+
12
+ def list_arm_platforms ():
13
+ return ['arm' , 'armv7l' , 'aarch64' , 'arm64' , 'ARM64' ]
10
14
11
15
class TestFloorDiv (CommonTFLayerTest ):
12
16
def create_add_placeholder_const_net (self , x_shape , dtype , ir_version , use_new_frontend ):
13
17
import tensorflow as tf
14
-
18
+ self . dtype = dtype
15
19
tf .compat .v1 .reset_default_graph ()
16
20
17
21
# Create the graph and model
18
22
with tf .compat .v1 .Session () as sess :
19
23
x = tf .compat .v1 .placeholder (dtype , x_shape , 'Input' )
20
24
constant_value = np .array (- 10 ).astype (dtype )
21
25
y = tf .constant (constant_value )
22
- x = tf .raw_ops .Abs (x = x )
23
26
res = tf .raw_ops .FloorDiv (x = x , y = y )
24
27
25
28
tf .compat .v1 .global_variables_initializer ()
@@ -29,12 +32,28 @@ def create_add_placeholder_const_net(self, x_shape, dtype, ir_version, use_new_f
29
32
30
33
return tf_net , ref_net
31
34
35
+ def _prepare_input (self , inputs_info ):
36
+ tensor_name = list (inputs_info .keys ())[0 ]
37
+ x_shape = inputs_info [tensor_name ]
38
+ inputs_data = {}
39
+ if np .issubdtype (self .dtype , np .floating ):
40
+ inputs_data [tensor_name ] = rng .uniform (- 5.0 , 5.0 , x_shape ).astype (self .dtype )
41
+ elif np .issubdtype (self .dtype , np .signedinteger ):
42
+ inputs_data [tensor_name ] = rng .integers (- 8 , 8 , x_shape ).astype (self .dtype )
43
+ else :
44
+ inputs_data [tensor_name ] = rng .integers (0 , 8 , x_shape ).astype (self .dtype )
45
+ return inputs_data
46
+
32
47
# TODO: implement tests for 2 Consts + Add
33
48
49
+
34
50
test_data_1D = [
35
51
dict (x_shape = [], dtype = np .int32 ),
36
52
dict (x_shape = [2 ], dtype = np .int64 ),
37
53
dict (x_shape = [2 , 4 , 5 ], dtype = np .int32 ),
54
+ dict (x_shape = [2 , 4 , 5 ], dtype = np .uint32 ),
55
+ dict (x_shape = [2 , 4 , 5 ], dtype = np .uint64 ),
56
+
38
57
dict (x_shape = [], dtype = np .float32 ),
39
58
dict (x_shape = [2 ], dtype = np .float64 ),
40
59
dict (x_shape = [2 , 4 , 5 ], dtype = np .float32 ),
@@ -45,7 +64,66 @@ def create_add_placeholder_const_net(self, x_shape, dtype, ir_version, use_new_f
45
64
@pytest .mark .precommit_tf_fe
46
65
def test_add_placeholder_const_1D (self , params , ie_device , precision , ir_version , temp_dir ,
47
66
use_new_frontend ):
67
+ if platform .system () == 'Linux' and platform .machine () in list_arm_platforms () and np .issubdtype (params ['dtype' ], np .signedinteger ):
68
+ pytest .xfail (reason = 'Ticket CVS-132377 - Divide inconsistent behavior on different systems' )
69
+
48
70
self ._test (* self .create_add_placeholder_const_net (** params , ir_version = ir_version ,
49
71
use_new_frontend = use_new_frontend ),
50
72
ie_device , precision , ir_version , temp_dir = temp_dir ,
51
73
use_new_frontend = use_new_frontend )
74
+
75
+
76
+ class TestFloorDivStaticInput (CommonTFLayerTest ):
77
+ min = - 100
78
+ max = 200
79
+ step = 1
80
+ dtype = np .int32
81
+
82
+ def create_flordiv_tf_net (self , min , max , step , y , dtype , ir_version , use_new_frontend ):
83
+ import tensorflow as tf
84
+ x = np .arange (min , max , step , dtype = dtype )
85
+
86
+ self .min = min
87
+ self .max = max
88
+ self .step = step
89
+ self .dtype = dtype
90
+
91
+ tf .compat .v1 .reset_default_graph ()
92
+
93
+ with tf .compat .v1 .Session () as sess :
94
+ x = tf .compat .v1 .placeholder (dtype , x .shape , 'Input' )
95
+ y = tf .constant (np .array (y ).astype (dtype ))
96
+ res = tf .raw_ops .FloorDiv (x = x , y = y )
97
+
98
+ tf .compat .v1 .global_variables_initializer ()
99
+ tf_net = sess .graph_def
100
+
101
+ ref_net = None
102
+
103
+ return tf_net , ref_net
104
+
105
+ def _prepare_input (self , inputs_dict ):
106
+ for input in inputs_dict .keys ():
107
+ inputs_dict [input ] = np .arange (self .min , self .max , self .step , dtype = self .dtype )
108
+ return inputs_dict
109
+
110
+ test_inputs = [
111
+ dict (min = - 20 , max = 20 , step = 1 , y = [10 ]),
112
+ dict (min = - 20 , max = 20 , step = 1 , y = [5 ]),
113
+ dict (min = - 20 , max = 20 , step = 1 , y = [6 ]),
114
+ dict (min = - 20 , max = 20 , step = 1 , y = [- 5 ]),
115
+ dict (min = - 20 , max = 20 , step = 1 , y = [- 6 ]),
116
+ dict (min = - 1e5 , max = 1e5 , step = 100 , y = [1e5 ]),
117
+ ]
118
+ @pytest .mark .parametrize ("params" , test_inputs )
119
+ @pytest .mark .parametrize ("dtype" , [np .int32 , np .int64 ])
120
+ @pytest .mark .nightly
121
+ @pytest .mark .precommit_tf_fe
122
+ @pytest .mark .xfail (condition = platform .system () == 'Linux' and platform .machine () in list_arm_platforms (),
123
+ reason = 'Ticket CVS-132377 - Divide inconsistent behavior on different systems' )
124
+ def test_floordiv (self , params , dtype , ie_device , precision , ir_version , temp_dir ,
125
+ use_new_frontend ):
126
+ self ._test (* self .create_flordiv_tf_net (** params , dtype = dtype , ir_version = ir_version ,
127
+ use_new_frontend = use_new_frontend ),
128
+ ie_device , precision , ir_version , temp_dir = temp_dir ,
129
+ use_new_frontend = use_new_frontend )
0 commit comments