Q: yolo v5 & TVM?

Hi,

I’m hacking on yolo v5 (on aarch64) with TVM. Just wondering if anyone has already worked with yolo v5 and TVM? No point in reinventing the wheel, likewise happy to work together with others that would have a similar interest.

Thanks!

1 Like

Sorry I remember seeing this question but forgot to answer last week.

Yes. Both of the following repos work with TVM.

See

Thanks for the pointer!

I’d tried the relay.frontend.from_pytorch(…) route prior and have had little luck with it. Using your code (https://github.com/masahi/torchscript-to-tvm/blob/master/yolo5/yolo5_test.py) this fails with:

mod, params = relay.frontend.from_pytorch(script_module, shape_list)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 3895, in from_pytorch
ret = converter.convert_operators(_get_operator_nodes(graph.nodes()), outputs, ret_name)[0]
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 3266, in convert_operators
if_out = self.convert_if(op_node, outputs)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 3105, in convert_if
false_branch = self.convert_block(blocks[1], outputs)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 3098, in convert_block
return self.convert_operators(ops, outputs, ret_names)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 3276, in convert_operators
inputs, _get_input_types(op_node, outputs, default_dtype=self.default_dtype)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 424, in slice
btype = self.infer_type(begin).dtype
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 156, in infer_type
new_node = tf.visit(node)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 93, in visit
v = super().visit(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 48, in visit
res = self.visit_call(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 217, in visit_call
new_args = [self.visit(arg) for arg in call.args]
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 217, in <listcomp>
new_args = [self.visit(arg) for arg in call.args]
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 93, in visit
v = super().visit(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 58, in visit
res = self.visit_tuple(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 230, in visit_tuple
return Tuple([self.visit(field) for field in tup.fields], tup.span)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 230, in <listcomp>
return Tuple([self.visit(field) for field in tup.fields], tup.span)
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 93, in visit
v = super().visit(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 48, in visit
res = self.visit_call(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 217, in visit_call
new_args = [self.visit(arg) for arg in call.args]
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 217, in <listcomp>
new_args = [self.visit(arg) for arg in call.args]
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 93, in visit
v = super().visit(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 48, in visit
res = self.visit_call(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 217, in visit_call
new_args = [self.visit(arg) for arg in call.args]
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 217, in <listcomp>
new_args = [self.visit(arg) for arg in call.args]
  File "/home/tgall/tvm/python/tvm/relay/frontend/pytorch.py", line 93, in visit
v = super().visit(expr)
  File "/home/tgall/tvm/python/tvm/relay/expr_functor.py", line 76, in visit
raise Exception("warning unhandled case: {0}".format(type(expr)))
Exception: warning unhandled case: <class 'NoneType'>

Have you updated your tvm install recently? I think I fixed it

ok! I’ll do a fresh pull and see where things are. I certainly admit my TVM pull is a few weeks old. Thanks!

You’re right, you’ve fixed it, thank you!

1 Like

Excuse me, which version of your TVM is?