@@ -438,9 +438,41 @@ def _test_upsample_bilinear():
438438 tvm_out = get_tvm_output (model , in_array , target , ctx , out_shape , 'float32' )
439439 tvm .testing .assert_allclose (out_array , tvm_out , rtol = 1e-5 , atol = 1e-5 )
440440
441+ def _test_upsample_bilinear_opset9 ():
442+ scale = 2
443+ in_shape = (1 , 1 , 3 , 3 )
444+ out_shape = (1 , 1 , 3 * scale , 3 * scale )
445+ y = helper .make_node ("Upsample" , ['in' ,'scales' ], ['out' ], mode = 'linear' )
446+ scales = [1.0 , 1.0 , 2.0 , 2.0 ]
447+ in_array = np .random .uniform (size = in_shape ).astype (np .float32 )
448+ out_array = topi .testing .bilinear_resize_python (in_array , (3 * scale , 3 * scale ), "NCHW" )
449+
450+ ref_array = np .array (scales )
451+ ref_node = helper .make_node ('Constant' ,
452+ inputs = [],
453+ outputs = ['scales' ],
454+ value = onnx .helper .make_tensor (name = 'const_tensor' ,
455+ data_type = TensorProto .FLOAT ,
456+ dims = ref_array .shape ,
457+ vals = ref_array .flatten ().astype (float )))
458+
459+ graph = helper .make_graph ([ref_node , y ],
460+ 'upsample_bilinear_opset9_test' ,
461+ inputs = [helper .make_tensor_value_info ("in" , TensorProto .FLOAT , list (in_shape ))],
462+ outputs = [helper .make_tensor_value_info ("out" , TensorProto .FLOAT , list (out_shape ))])
463+
464+ model = helper .make_model (graph , producer_name = 'upsample_bilinear_opset9_test' )
465+ inputs = []
466+ inputs .append (in_array )
467+
468+ for target , ctx in ctx_list ():
469+ tvm_out = get_tvm_output (model , inputs , target , ctx , out_shape , 'float32' )
470+ tvm .testing .assert_allclose (out_array , tvm_out , rtol = 1e-5 , atol = 1e-5 )
471+
441472def test_upsample ():
442473 _test_upsample_nearest ()
443474 _test_upsample_bilinear ()
475+ _test_upsample_bilinear_opset9 ()
444476
445477def _test_softmax (inshape , axis ):
446478 opname = 'Softmax'
0 commit comments