@@ -45,49 +45,33 @@ def test_multibox_prior():
45
45
46
46
47
47
def test_yolo_reorg ():
48
- ib = relay .ir_builder .IRBuilder ()
49
48
n , c , h , w = tvm .var ("n" ), tvm .var ("c" ), tvm .var ("h" ), tvm .var ("w" )
50
- x = ib .param ("x" , relay .ty .TensorType ((n , c , h , w ), "float32" ))
51
- with ib .function (x ) as func :
52
- ib .ret (relay .vision .yolo_reorg (x ))
53
- ib .ret (func )
54
- func = relay .ir_pass .infer_type (ib .env , func .to_func ())
55
- ftype = func .checked_type
56
- assert ftype .ret_type == relay .ty .TensorType ((n , c , h , w ), "float32" )
57
-
58
- ib = relay .ir_builder .IRBuilder ()
59
- x = ib .param ("x" , relay .ty .TensorType ((n , c , h , w ), "float32" ))
49
+ x = relay .var ("x" , relay .TensorType ((n , c , h , w ), "float32" ))
50
+ z = relay .vision .yolo_reorg (x )
51
+ zz = relay .ir_pass .infer_type (z )
52
+ assert zz .checked_type == relay .ty .TensorType ((n , c , h , w ), "float32" )
60
53
61
- with ib .function (x ) as func :
62
- ib .ret (relay .vision .yolo_reorg (x , stride = 2 ))
63
- ib .ret (func )
64
- func = relay .ir_pass .infer_type (ib .env , func .to_func ())
65
- ftype = func .checked_type
66
- assert ftype .ret_type == relay .ty .TensorType ((n , c * 2 * 2 , h / 2 , w / 2 ), "float32" )
54
+ x = relay .var ("x" , relay .TensorType ((n , c , h , w ), "float32" ))
55
+ z = relay .vision .yolo_reorg (x , stride = 2 )
56
+ assert "stride=2" in z .astext ()
57
+ zz = relay .ir_pass .infer_type (z )
58
+ assert zz .checked_type == relay .ty .TensorType ((n , c * 2 * 2 , h / 2 , w / 2 ), "float32" )
67
59
68
60
69
61
def test_yolo_region ():
70
- ib = relay .ir_builder .IRBuilder ()
71
62
n , c , h , w = tvm .var ("n" ), tvm .var ("c" ), tvm .var ("h" ), tvm .var ("w" )
72
- x = ib .param ("x" , relay .ty .TensorType ((n , c , h , w ), "float32" ))
73
- with ib .function (x ) as func :
74
- ib .ret (relay .vision .yolo_region (x ))
75
- ib .ret (func )
76
- func = relay .ir_pass .infer_type (ib .env , func .to_func ())
77
- ftype = func .checked_type
78
- assert ftype .ret_type == relay .ty .TensorType ((n , c , h , w ), "float32" )
63
+ x = relay .var ("x" , relay .TensorType ((n , c , h , w ), "float32" ))
64
+ z = relay .vision .yolo_region (x )
65
+ zz = relay .ir_pass .infer_type (z )
66
+ assert zz .checked_type == relay .ty .TensorType ((n , c , h , w ), "float32" )
79
67
80
68
81
69
def test_yolov3_yolo ():
82
- ib = relay .ir_builder .IRBuilder ()
83
70
n , c , h , w = tvm .var ("n" ), tvm .var ("c" ), tvm .var ("h" ), tvm .var ("w" )
84
- x = ib .param ("x" , relay .ty .TensorType ((n , c , h , w ), "float32" ))
85
- with ib .function (x ) as func :
86
- ib .ret (relay .vision .yolov3_yolo (x ))
87
- ib .ret (func )
88
- func = relay .ir_pass .infer_type (ib .env , func .to_func ())
89
- ftype = func .checked_type
90
- assert ftype .ret_type == relay .ty .TensorType ((n , c , h , w ), "float32" )
71
+ x = relay .var ("x" , relay .TensorType ((n , c , h , w ), "float32" ))
72
+ z = relay .vision .yolov3_yolo (x )
73
+ zz = relay .ir_pass .infer_type (z )
74
+ assert zz .checked_type == relay .ty .TensorType ((n , c , h , w ), "float32" )
91
75
92
76
93
77
if __name__ == "__main__" :
0 commit comments