You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by 王鹤男 via Apache TVM Discuss <no...@discuss.tvm.ai> on 2020/09/29 07:48:06 UTC

[Apache TVM Discuss] [Questions] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’


I am working on a case: compile a pytorch model using tvm on g4dn. 

But I encountered a problem that the tensor conversion between tvm and pytorch is too slow, since some pre-process and post-process are implemented using pytorch. 

I found that DLPACK maybe helpful in this case, thus I tried the example here (https://tvm.apache.org/2018/08/10/DLPack-Bridge). The example works well, but when it comes to my pytorch model, I got the error when calling the converted model: [AttributeError: Module has no function ‘__tvm_main__’].

Can anybody help me on this case? Thank you!





---
[Visit Topic](https://discuss.tvm.apache.org/t/dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/a7694f71b182d6891b09a4b32d28e52b5386df72e15ee8178cb957621ddff372).

[Apache TVM Discuss] [Questions] [SOVLED] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

I see..That makes sense





---
[Visit Topic](https://discuss.tvm.apache.org/t/sovled-dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/8) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/c059ff2b438bed76e71fddba0d26ba95f0c1c1f6ed487b1795cb481ec6337153).

[Apache TVM Discuss] [Questions] [SOVLED] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by "Cody H. Yu via Apache TVM Discuss" <no...@discuss.tvm.ai>.

I think the confusion part is mainly coming from different use cases. The tutorial uses the TE functions while @whn09 is working on a Relay graph.





---
[Visit Topic](https://discuss.tvm.apache.org/t/sovled-dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/7) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/ae8ea63fd6df63c727a03a21c5095c6528251a3eb74b4f1d0cad388eeb1f6b30).

[Apache TVM Discuss] [Questions] [SOVLED] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by 王鹤男 via Apache TVM Discuss <no...@discuss.tvm.ai>.

I found that I can simply use DLPACK to convert tvm tensor to pytorch tensor and vice versa. The problem has been solved!

    from torch.utils.dlpack import to_dlpack, from_dlpack
    from tvm.runtime import ndarray
    ...
    m.set_input('input1', ndarray.from_dlpack(to_dlpack(input1)))
    ...
    pytorch_output = from_dlpack(tvm_output.to_dlpack())





---
[Visit Topic](https://discuss.tvm.apache.org/t/sovled-dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/5) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/f30bf38d1cfc1c52b2e394a8202e5e3a9e4e455cfc1413d6e98345f45d23b89c).

[Apache TVM Discuss] [Questions] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by 王鹤男 via Apache TVM Discuss <no...@discuss.tvm.ai>.

I removed the (ctx), and the error has been solved. But I got another error: TVMError: Check failed: type_code_ == kTVMContext (13 vs. 6) : expected TVMContext but get NDArrayContainer





---
[Visit Topic](https://discuss.tvm.apache.org/t/dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/7b624f024a01785c1647c2bffd63964d1b0b66cbfee761e76b37085cc5776c50).

[Apache TVM Discuss] [Questions] [SOVLED] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by Junru Shao via Apache TVM Discuss <no...@discuss.tvm.ai>.

Would you like to kindly post where the confusing part is, and possibly submit a PR to improve the documentation? That would be super helpful! Thanks!





---
[Visit Topic](https://discuss.tvm.apache.org/t/sovled-dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/6) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/7aa4d8a9a832cdf434c544b4cf6a8c1dbd14a38ec107a3085ecefad1e5cd2b2a).

[Apache TVM Discuss] [Questions] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by 王鹤男 via Apache TVM Discuss <no...@discuss.tvm.ai>.

Sample code:

from tvm.contrib.dlpack import to_pytorch_func
m_pytorch = to_pytorch_func(lib\['default'\](ctx))

torch_output = torch.empty(1, 40, 120, 256)
m_pytorch(input1, input2, input3, torch_output)





---
[Visit Topic](https://discuss.tvm.apache.org/t/dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/ad2e83da728c653b5432bc5389e391b829e751ac5fe712eb187dfd3880e626e6).

[Apache TVM Discuss] [Questions] DLPACK ERROR: AttributeError: Module has no function ‘__tvm_main__’

Posted by 王鹤男 via Apache TVM Discuss <no...@discuss.tvm.ai>.

I found that the example use [[tvm.build](http://tvm.build/)], but my code use [[tvm.relay.build](http://tvm.relay.build/)]. I think it is the reason. But if I use [[tvm.build](http://tvm.build/)] in my code, it may not work. So, what’s the difference between [[tvm.build](http://tvm.build/)] and [[tvm.relay.build](http://tvm.relay.build/)]?





---
[Visit Topic](https://discuss.tvm.apache.org/t/dlpack-error-attributeerror-module-has-no-function-tvm-main/8029/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/a7d1ee1872ddef4a17188bb09c239e8893150093c0ebcea1d5956a106afa3846).