@@ -1529,7 +1529,10 @@ def test_resize_nearest_neighbor(self):
1529
1529
_ = tf .identity (x_ , name = _TFOUTPUT )
1530
1530
graph = self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1531
1531
if self .config .opset >= 9 :
1532
- scale_node = group_nodes_by_type (graph )["Upsample" ][0 ].inputs [1 ]
1532
+ # in opset 10, upsample is removed and resize is defined.
1533
+ node_statistic = group_nodes_by_type (graph )
1534
+ mapped_node = (node_statistic .get ("Upsample" ) or node_statistic .get ("Resize" ))[0 ]
1535
+ scale_node = mapped_node .inputs [1 ]
1533
1536
self .assertTrue (validate_const_node (scale_node , [1.0 , 1.0 , 2.0 , 2.0 ]))
1534
1537
1535
1538
@check_opset_min_version (9 , "resize_nearest_neighbor" )
@@ -1557,7 +1560,10 @@ def test_resize_bilinear(self):
1557
1560
_ = tf .identity (x_ , name = _TFOUTPUT )
1558
1561
graph = self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1559
1562
if self .config .opset >= 9 :
1560
- scale_node = group_nodes_by_type (graph )["Upsample" ][0 ].inputs [1 ]
1563
+ # in opset 10, upsample is removed and resize is defined.
1564
+ node_statistic = group_nodes_by_type (graph )
1565
+ mapped_node = (node_statistic .get ("Upsample" ) or node_statistic .get ("Resize" ))[0 ]
1566
+ scale_node = mapped_node .inputs [1 ]
1561
1567
self .assertTrue (validate_const_node (scale_node , [1.0 , 1.0 , 2.0 , 2.0 ]))
1562
1568
1563
1569
@check_opset_min_version (9 , "resize_bilinear" )
@@ -1573,6 +1579,35 @@ def test_resize_bilinear_with_non_const(self):
1573
1579
_ = tf .identity (x_ , name = _TFOUTPUT )
1574
1580
self ._run_test_case ([_OUTPUT ], {_INPUT : x_val , _INPUT1 : x_new_size })
1575
1581
1582
+ @check_opset_min_version (10 , "resize scale can less than 1" )
1583
+ def test_resize_bilinear_with_non_const2 (self ):
1584
+ # scales has an element larger than 1 and also has an element less that 1
1585
+ x_shape = [3 , 100 , 8 , 5 ]
1586
+ x_val = np .arange (1 , 1 + np .prod (x_shape ), dtype = np .float32 ).reshape (x_shape )
1587
+ x = tf .placeholder (tf .float32 , x_shape , name = _TFINPUT )
1588
+
1589
+ x_new_size = np .array ([20 , 16 ]).astype (np .int32 )
1590
+ x_new_size_ = tf .placeholder (shape = [None ], dtype = tf .int32 , name = _TFINPUT1 )
1591
+
1592
+ x_ = tf .image .resize_bilinear (x , x_new_size_ )
1593
+ _ = tf .identity (x_ , name = _TFOUTPUT )
1594
+ self ._run_test_case ([_OUTPUT ], {_INPUT : x_val , _INPUT1 : x_new_size })
1595
+
1596
+ @check_opset_min_version (10 , "resize scale can less than 1" )
1597
+ def test_resize_nearest_neighbor2 (self ):
1598
+ x_shape = [1 , 300 , 20 , 2 ]
1599
+ x_new_size = [30 , 40 ]
1600
+ x_val = np .arange (1 , 1 + np .prod (x_shape )).astype ("float32" ).reshape (x_shape )
1601
+ x = tf .placeholder (tf .float32 , x_shape , name = _TFINPUT )
1602
+ x_new_size_ = tf .constant (x_new_size )
1603
+ x_ = tf .image .resize_nearest_neighbor (x , x_new_size_ )
1604
+ _ = tf .identity (x_ , name = _TFOUTPUT )
1605
+ graph = self ._run_test_case ([_OUTPUT ], {_INPUT : x_val })
1606
+ node_statistic = group_nodes_by_type (graph )
1607
+ mapped_node = node_statistic .get ("Resize" )[0 ]
1608
+ scale_node = mapped_node .inputs [1 ]
1609
+ self .assertTrue (validate_const_node (scale_node , [1.0 , 1.0 , 0.1 , 2.0 ]))
1610
+
1576
1611
@check_opset_min_version (9 , "fill" )
1577
1612
def test_fill_float32 (self ):
1578
1613
x_shape = [1 , 15 , 20 , 2 ]
0 commit comments