@@ -724,7 +724,6 @@ def test_equal(self):
724
724
_ = tf .identity (mi , name = _TFOUTPUT )
725
725
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val1 , _INPUT1 : x_val2 })
726
726
727
-
728
727
def test_sequeeze_no_axis_specified (self ):
729
728
x_val = np .array ([1.0 , 2.0 , 3.0 , 4.0 ], dtype = np .float32 ).reshape ((2 , 2 , 1 ))
730
729
x = tf .placeholder (tf .float32 , [2 , 2 , 1 ], name = _TFINPUT )
@@ -982,14 +981,14 @@ def test_slice1(self):
982
981
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
983
982
984
983
def test_split (self ):
985
- x_val = np .linspace (1.0 , 5 * 30.0 , 5 * 30 ).astype (np .float32 ).reshape (5 , 30 )
984
+ x_val = np .linspace (1.0 , 5 * 30.0 , 5 * 30 ).astype (np .float32 ).reshape (( 5 , 30 ) )
986
985
x0 = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
987
986
x_ , _ , _ = tf .split (x0 , [4 , 15 , 11 ], 1 )
988
987
_ = tf .identity (x_ , name = _TFOUTPUT )
989
988
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
990
989
991
990
def test_split_with_more_outputs (self ):
992
- x_val = np .linspace (1.0 , 5 * 30.0 , 5 * 30 ).astype (np .float32 ).reshape (5 , 30 )
991
+ x_val = np .linspace (1.0 , 5 * 30.0 , 5 * 30 ).astype (np .float32 ).reshape (( 5 , 30 ) )
993
992
x0 = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
994
993
_ , _ , _ = tf .split (x0 , [4 , 15 , 11 ], 1 , name = "split_test" )
995
994
self ._run_test_case (["split_test:0" , "split_test:1" , "split_test:2" ], {_INPUT : x_val })
@@ -1418,36 +1417,36 @@ def test_addn(self):
1418
1417
1419
1418
@skip_caffe2_backend ("multiple dims not supported" )
1420
1419
def test_strided_slice1 (self ):
1421
- x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (3 , 2 , 3 )
1420
+ x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (( 3 , 2 , 3 ) )
1422
1421
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1423
1422
x_ = tf .strided_slice (x , [1 , 0 , 0 ], [2 , 1 , 3 ], [1 , 1 , 1 ])
1424
1423
_ = tf .identity (x_ , name = _TFOUTPUT )
1425
1424
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1426
1425
1427
1426
def test_strided_slice2 (self ):
1428
- x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (3 , 2 , 3 )
1427
+ x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (( 3 , 2 , 3 ) )
1429
1428
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1430
1429
x_ = tf .strided_slice (x , [1 , 0 , 0 ], [2 , 2 , 3 ], [1 , 1 , 1 ])
1431
1430
_ = tf .identity (x_ , name = _TFOUTPUT )
1432
1431
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1433
1432
1434
1433
def test_strided_slice3 (self ):
1435
- x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (3 , 2 , 3 )
1434
+ x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (( 3 , 2 , 3 ) )
1436
1435
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1437
1436
x_ = x [1 :]
1438
1437
_ = tf .identity (x_ , name = _TFOUTPUT )
1439
1438
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1440
1439
1441
1440
def test_strided_slice4 (self ):
1442
- x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (3 , 2 , 3 )
1441
+ x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (( 3 , 2 , 3 ) )
1443
1442
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1444
1443
x_ = x [:2 ]
1445
1444
_ = tf .identity (x_ , name = _TFOUTPUT )
1446
1445
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1447
1446
1448
1447
@skip_caffe2_backend ("multiple dims not supported" )
1449
1448
def test_strided_slice5 (self ):
1450
- x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (3 , 2 , 3 )
1449
+ x_val = np .arange (3 * 2 * 3 ).astype ("float32" ).reshape (( 3 , 2 , 3 ) )
1451
1450
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1452
1451
x_ = x [:2 , 0 :1 , 1 :]
1453
1452
_ = tf .identity (x_ , name = _TFOUTPUT )
@@ -1457,15 +1456,15 @@ def test_strided_slice5(self):
1457
1456
def test_strided_slice6 (self ):
1458
1457
# example from here:
1459
1458
# https://www.tensorflow.org/versions/r1.0/api_docs/cc/class/tensorflow/ops/strided-slice
1460
- x_val = np .arange (5 * 6 ).astype ("float32" ).reshape (5 , 6 )
1459
+ x_val = np .arange (5 * 6 ).astype ("float32" ).reshape (( 5 , 6 ) )
1461
1460
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1462
1461
x_ = x [2 , :]
1463
1462
_ = tf .identity (x_ , name = _TFOUTPUT )
1464
1463
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1465
1464
1466
1465
@skip_caffe2_backend ("multiple dims not supported" )
1467
1466
def test_strided_slice7 (self ):
1468
- x_val = np .arange (5 * 6 ).astype ("float32" ).reshape (5 , 6 )
1467
+ x_val = np .arange (5 * 6 ).astype ("float32" ).reshape (( 5 , 6 ) )
1469
1468
1470
1469
x = tf .placeholder (tf .float32 , x_val .shape , name = _TFINPUT )
1471
1470
x_ = tf .strided_slice (x , [0 , 1 ], [3 , 4 ], [1 , 1 ], begin_mask = 2 )
@@ -1684,19 +1683,17 @@ def test_erf(self):
1684
1683
_ = tf .identity (x_ , name = _TFOUTPUT )
1685
1684
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, rtol = 0.01 )
1686
1685
1687
- def _test_reverse_sequence_batch_major (self , extra_opset = None ):
1688
- process_args = {}
1689
- if extra_opset is not None :
1690
- process_args ["extra_opset" ] = [extra_opset ]
1691
-
1686
+ @check_opset_min_version (8 , "Scan" )
1687
+ @skip_opset (9 , "ReverseSequence" )
1688
+ def test_reverse_sequence_batch_major (self ):
1692
1689
x_val = np .array ([[[1 , 2 , 3 ], [4 , 5 , 6 ], [0 , 0 , 0 ]],
1693
1690
[[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]],
1694
1691
[[1 , 2 , 3 ], [0 , 0 , 0 ], [0 , 0 , 0 ]]],
1695
1692
dtype = np .float32 )
1696
1693
x = tf .placeholder (tf .float32 , [None , 3 , 3 ], name = _TFINPUT )
1697
1694
x_ = tf .reverse_sequence (x , seq_axis = 1 , batch_axis = 0 , seq_lengths = [2 , 3 , 1 ])
1698
1695
_ = tf .identity (x_ , name = _TFOUTPUT )
1699
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, process_args = process_args )
1696
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1700
1697
tf .reset_default_graph ()
1701
1698
1702
1699
x_val = np .array ([[1 , 2 , 3 ], [1 , 2 , 3 ], [1 , 2 , 3 ],
@@ -1707,70 +1704,45 @@ def _test_reverse_sequence_batch_major(self, extra_opset=None):
1707
1704
x = tf .placeholder (tf .float32 , [None , 3 ], name = _TFINPUT )
1708
1705
x_ = tf .reverse_sequence (x , seq_axis = 1 , batch_axis = 0 , seq_lengths = [3 ] * 9 )
1709
1706
_ = tf .identity (x_ , name = _TFOUTPUT )
1710
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, process_args = process_args )
1707
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1711
1708
tf .reset_default_graph ()
1712
1709
1713
1710
x_val_shape = [5 , 5 , 7 , 8 , 9 ]
1714
1711
x_val = np .random .randint (0 , 100 , x_val_shape ).astype (np .float32 )
1715
1712
x = tf .placeholder (tf .float32 , [None , 5 , 7 , 8 , 9 ], name = _TFINPUT )
1716
1713
x_ = tf .reverse_sequence (x , seq_axis = 1 , batch_axis = 0 , seq_lengths = [5 , 5 , 5 , 5 , 5 ])
1717
1714
_ = tf .identity (x_ , name = _TFOUTPUT )
1718
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, process_args = process_args )
1719
-
1720
- def _test_reverse_sequence_time_major (self , extra_opset = None ):
1721
- process_args = {}
1722
- if extra_opset is not None :
1723
- process_args ["extra_opset" ] = [extra_opset ]
1715
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1724
1716
1717
+ @check_opset_min_version (8 , "Scan" )
1718
+ @skip_opset (9 , "ReverseSequence" )
1719
+ def test_reverse_sequence_time_major (self ):
1725
1720
x_val = np .array ([[[1 , 2 , 3 ], [1 , 2 , 3 ], [1 , 2 , 3 ]],
1726
1721
[[4 , 5 , 6 ], [4 , 5 , 6 ], [0 , 0 , 0 ]],
1727
- [[0 , 0 , 0 ], [7 , 8 , 9 ], [0 , 0 , 0 ]]
1728
- ],
1722
+ [[0 , 0 , 0 ], [7 , 8 , 9 ], [0 , 0 , 0 ]]],
1729
1723
dtype = np .float32 )
1730
1724
x = tf .placeholder (tf .float32 , [3 , None , 3 ], name = _TFINPUT )
1731
1725
x_ = tf .reverse_sequence (x , seq_axis = 0 , batch_axis = 1 , seq_lengths = [2 , 3 , 1 ])
1732
1726
_ = tf .identity (x_ , name = _TFOUTPUT )
1733
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, process_args = process_args )
1727
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1734
1728
tf .reset_default_graph ()
1735
1729
1736
1730
x_val = np .array ([[1 , 2 , 3 ], [1 , 2 , 3 ], [1 , 2 , 3 ],
1737
1731
[4 , 5 , 6 ], [4 , 5 , 6 ], [1 , 1 , 1 ],
1738
- [0 , 0 , 0 ], [7 , 8 , 9 ], [0 , 0 , 0 ]
1739
- ],
1732
+ [0 , 0 , 0 ], [7 , 8 , 9 ], [0 , 0 , 0 ]],
1740
1733
dtype = np .float32 )
1741
1734
x = tf .placeholder (tf .float32 , [9 , None ], name = _TFINPUT )
1742
1735
x_ = tf .reverse_sequence (x , seq_axis = 0 , batch_axis = 1 , seq_lengths = [9 , 9 , 9 ])
1743
1736
_ = tf .identity (x_ , name = _TFOUTPUT )
1744
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, process_args = process_args )
1737
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1745
1738
tf .reset_default_graph ()
1746
1739
1747
1740
x_val_shape = [5 , 5 , 7 , 8 , 9 ]
1748
1741
x_val = np .random .randint (0 , 100 , x_val_shape ).astype (np .float32 )
1749
1742
x = tf .placeholder (tf .float32 , [5 , None , 7 , 8 , 9 ], name = _TFINPUT )
1750
1743
x_ = tf .reverse_sequence (x , seq_axis = 0 , batch_axis = 1 , seq_lengths = [5 , 5 , 5 , 5 , 5 ])
1751
1744
_ = tf .identity (x_ , name = _TFOUTPUT )
1752
- self ._run_test_case ([_OUTPUT ], {_INPUT : x_val }, process_args = process_args )
1753
-
1754
- @check_opset_min_version (8 , "Scan" )
1755
- @skip_opset (9 , "ReverseSequence" )
1756
- def test_reverse_sequence_batch_major (self ):
1757
- self ._test_reverse_sequence_batch_major ()
1758
-
1759
- @check_opset_min_version (8 , "Scan" )
1760
- @skip_opset (9 , "ReverseSequence" )
1761
- def test_reverse_sequence_time_major (self ):
1762
- self ._test_reverse_sequence_time_major ()
1763
-
1764
- # only support onnxruntime with version larger than 0.4.0
1765
- @test_ms_domain ()
1766
- @check_onnxruntime_min_version ("0.4.0" )
1767
- def test_ms_reverse_sequence_batch_major (self , extra_opset ):
1768
- self ._test_reverse_sequence_batch_major (extra_opset )
1769
-
1770
- @test_ms_domain ()
1771
- @check_onnxruntime_min_version ("0.4.0" )
1772
- def test_ms_reverse_sequence_time_major (self , extra_opset ):
1773
- self ._test_reverse_sequence_time_major (extra_opset )
1745
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1774
1746
1775
1747
@check_opset_min_version (8 , "where" )
1776
1748
def test_where (self ):
0 commit comments