@@ -173,6 +173,17 @@ def test_trig_ops(self):
173
173
174
174
@unittest .skipIf (BACKEND in ["caffe2" , "onnxmsrt" ], "not supported correctly in caffe2" )
175
175
def test_multinomial (self ):
176
+ x_val = np .array ([[10. , 10. ]], dtype = np .float32 )
177
+ x = tf .placeholder (tf .float32 , shape = x_val .shape , name = _TFINPUT )
178
+ op = tf .multinomial (tf .log (x ), 5 , output_dtype = tf .int64 )
179
+ output = tf .identity (op , name = _TFOUTPUT )
180
+ actual , expected = self ._run (output , {x : x_val }, {_INPUT : x_val })
181
+ # since returned indexes are random we can only check type and shape
182
+ self .assertEqual (expected .dtype , actual .dtype )
183
+ self .assertEqual (expected .shape , actual .shape )
184
+
185
+ @unittest .skipIf (BACKEND in ["caffe2" , "onnxmsrt" ], "not supported correctly in caffe2" )
186
+ def test_multinomial1 (self ):
176
187
shape = [2 , 10 ]
177
188
x_val = np .ones (np .prod (shape )).astype ("float32" ).reshape (shape )
178
189
x = tf .placeholder (tf .float32 , shape = x_val .shape , name = _TFINPUT )
@@ -181,7 +192,7 @@ def test_multinomial(self):
181
192
actual , expected = self ._run (output , {x : x_val }, {_INPUT : x_val })
182
193
# since returned indexes are random we can only check type and shape
183
194
self .assertEqual (expected .dtype , actual .dtype )
184
- self .assertAllClose (expected .shape , actual .shape )
195
+ self .assertEqual (expected .shape , actual .shape )
185
196
186
197
def test_maxppol (self ):
187
198
x_val = make_xval ((1 , 4 , 4 , 1 ))
@@ -462,13 +473,25 @@ def test_square(self):
462
473
def test_min (self ):
463
474
x_val1 = np .array ([4.0 , 16.0 , 4.0 , 1.6 ], dtype = np .float32 ).reshape ((2 , 2 ))
464
475
x_val2 = np .array ([4.0 , 4.0 , 4.0 , 4.0 ], dtype = np .float32 ).reshape ((2 , 2 ))
465
- x1 = tf .placeholder (tf .float32 , [ 2 , 2 ] , name = _TFINPUT )
466
- x2 = tf .placeholder (tf .float32 , [ 2 , 2 ] , name = _TFINPUT1 )
476
+ x1 = tf .placeholder (tf .float32 , x_val1 . shape , name = _TFINPUT )
477
+ x2 = tf .placeholder (tf .float32 , x_val2 . shape , name = _TFINPUT1 )
467
478
mi = tf .minimum (x1 , x2 )
468
479
output = tf .identity (mi , name = _TFOUTPUT )
469
480
actual , expected = self ._run (output , {x1 : x_val1 , x2 : x_val2 }, {_INPUT : x_val1 , _INPUT1 : x_val2 , })
470
481
self .assertAllClose (expected , actual )
471
482
483
+ @unittest .skipIf (BACKEND in ["caffe2" , "onnxmsrt" ], "issue with broadcastnig scalar" )
484
+ def test_min_broadcast (self ):
485
+ # tests if the broadcast for min/max is working
486
+ x_val1 = np .array ([2.0 , 16.0 , 5.0 , 1.6 ], dtype = np .float32 ).reshape ((2 , 2 ))
487
+ x_val2 = np .array ([4.0 ], dtype = np .float32 )
488
+ x1 = tf .placeholder (tf .float32 , x_val1 .shape , name = _TFINPUT )
489
+ x2 = tf .constant (x_val2 , dtype = tf .float32 , name = 'x2' )
490
+ mi = tf .minimum (x1 , x2 )
491
+ output = tf .identity (mi , name = _TFOUTPUT )
492
+ actual , expected = self ._run (output , {x1 : x_val1 }, {_INPUT : x_val1 })
493
+ self .assertAllClose (expected , actual )
494
+
472
495
def test_logicaland (self ):
473
496
x_val1 = np .array ([1 , 0 , 1 , 1 ], dtype = np .bool ).reshape ((2 , 2 ))
474
497
x_val2 = np .array ([0 , 1 , 1 , 1 ], dtype = np .bool ).reshape ((2 , 2 ))
@@ -712,7 +735,6 @@ def test_pad(self):
712
735
713
736
@unittest .skipIf (BACKEND in ["caffe2" , "onnxmsrt" ], "not supported correctly in caffe2" )
714
737
def test_randomuniform (self ):
715
- # not supported by onnxmsrt or caffe2
716
738
shape = tf .constant ([2 , 3 ], name = "shape" )
717
739
x_ = tf .random_uniform (shape , name = "rand" , dtype = tf .float32 )
718
740
x_ = tf .identity (x_ , name = "output1" )
@@ -722,6 +744,17 @@ def test_randomuniform(self):
722
744
# since results are random, compare the shapes only
723
745
self .assertAllClose (expected .shape , actual .shape )
724
746
747
+ @unittest .skip
748
+ def test_randomuniform_int (self ):
749
+ shape = tf .constant ([2 , 3 ], name = "shape" )
750
+ x_ = tf .random_uniform (shape , name = "rand" , dtype = tf .int32 , maxval = 10 )
751
+ x_ = tf .identity (x_ , name = "output1" )
752
+ x_ = tf .identity (x_ , name = "output2" )
753
+ output = tf .identity (x_ , name = _TFOUTPUT )
754
+ actual , expected = self ._run (output , {}, {})
755
+ # since results are random, compare the shapes only
756
+ self .assertAllClose (expected .shape , actual .shape )
757
+
725
758
@unittest .skip
726
759
def test_argminmax (self ):
727
760
# TODO: fails on onnxmsrt caffe2
0 commit comments