Skip to content

Commit 07bbf70

Browse files
committed
Test cases updated
1 parent a8c514d commit 07bbf70

File tree

1 file changed

+17
-33
lines changed

1 file changed

+17
-33
lines changed

tests/python/relay/test_op_level5.py

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -45,49 +45,33 @@ def test_multibox_prior():
4545

4646

4747
def test_yolo_reorg():
48-
ib = relay.ir_builder.IRBuilder()
4948
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")
6053

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")
6759

6860

6961
def test_yolo_region():
70-
ib = relay.ir_builder.IRBuilder()
7162
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")
7967

8068

8169
def test_yolov3_yolo():
82-
ib = relay.ir_builder.IRBuilder()
8370
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")
9175

9276

9377
if __name__ == "__main__":

0 commit comments

Comments
 (0)