tvm icon indicating copy to clipboard operation
tvm copied to clipboard

Converting torch.RNN to TVM Relay

Open kaimast opened this issue 6 years ago • 4 comments

Hi all,

I'm trying to pass a torch model I trained to TVM. It's a RNN that takes a PackedSequence as an input. torch_tvm.to_relay only seems to like tensors as input so I'm getting the following error.

RuntimeError: Tracer cannot infer type of (PackedSequence(...

Any idea how I can work around this? Let me know if I'm using the TVM bindings the wrong way.

Thanks!

kaimast avatar Aug 16 '19 22:08 kaimast

Oh d'uh. RNN also takes a regular tensor as input...

However, now I get this error. Can I not convert an entire neural network into a relay? Do i have to do it layer by layer?

RuntimeError: This program cannot be exported as a single Relay expression. (operator() at /home/kai/dev/torch-tvm/torch_tvm/register.
cpp:87)
frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const
&) + 0x65 (0x7f6cde810455 in /usr/local/lib/python3.7/dist-packages/torch/lib/libc10.so)                                             
frame #1: <unknown function> + 0x29e4f (0x7f6cb4ccfe4f in /home/kai/.local/lib/python3.7/site-packages/torch_tvm/_torch_tvm.cpython-37
m-x86_64-linux-gnu.so)
frame #2: <unknown function> + 0x302a7 (0x7f6cb4cd62a7 in /home/kai/.local/lib/python3.7/site-packages/torch_tvm/_torch_tvm.cpython-37
m-x86_64-linux-gnu.so)
frame #3: _PyMethodDef_RawFastCallKeywords + 0x224 (0x5d8014 in /usr/bin/python3)                                                    
frame #4: _PyEval_EvalFrameDefault + 0x4293 (0x551fd3 in /usr/bin/python3)                                                           
frame #5: _PyFunction_FastCallKeywords + 0x18c (0x5d896c in /usr/bin/python3)                                                        
frame #6: /usr/bin/python3() [0x54af20]
frame #7: _PyEval_EvalFrameDefault + 0x4457 (0x552197 in /usr/bin/python3)
frame #8: _PyFunction_FastCallKeywords + 0x18c (0x5d896c in /usr/bin/python3)
frame #9: _PyEval_EvalFrameDefault + 0x500 (0x54e240 in /usr/bin/python3)
frame #10: _PyEval_EvalCodeWithName + 0x252 (0x54b9f2 in /usr/bin/python3)
frame #11: PyEval_EvalCode + 0x23 (0x54dd33 in /usr/bin/python3)
frame #12: /usr/bin/python3() [0x630f22]
frame #13: PyRun_FileExFlags + 0x97 (0x630fd7 in /usr/bin/python3)
frame #14: PyRun_SimpleFileExFlags + 0x17f (0x631c3f in /usr/bin/python3)
frame #15: /usr/bin/python3() [0x65414e]
frame #16: _Py_UnixMain + 0x2e (0x6544ae in /usr/bin/python3)
frame #17: __libc_start_main + 0xeb (0x7f6cf81d8b6b in /lib/x86_64-linux-gnu/libc.so.6)
frame #18: _start + 0x2a (0x5e04ea in /usr/bin/python3)

kaimast avatar Aug 18 '19 04:08 kaimast

I don't think we support RNN to relay now.

yinghai avatar Aug 20 '19 03:08 yinghai

I figured. Is it planned for a future release?

kaimast avatar Aug 20 '19 03:08 kaimast

As far as I understand, this is not planned. If you are interested, you are welcome to help.

yinghai avatar Aug 28 '19 20:08 yinghai