AttributeError when import tvm.relay

Hi,

I guess this is related to some recent commits, so I will trace back some older version that works. But for reference, after pulling the repo a few minutes ago, this error appears when I run the tutorial that converts an ONNX model:

Traceback (most recent call last):
  File "01_from_onnx.py", line 50, in <module>
    import tvm.relay as relay
  File "/home/curzel/tvm/python/tvm/relay/__init__.py", line 22, in <module>
    from . import ty
  File "/home/curzel/tvm/python/tvm/relay/ty.py", line 23, in <module>
    Any = _make.Any
AttributeError: module 'tvm.relay._make' has no attribute 'Any'
2 Likes

Hi, did you fix the error?

Did you recompile tvm?

Yes, everything works after recompiling. Sorry if I did not update the post.

@SerenaC94 @hgt312 I am getting the same error whiile trying to use main branch on top of Xilinx EDGE device. Tried recompiling and reinstalling. didnt help - any suggestion?

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/root/tvm/python/tvm/relay/__init__.py", line 23, in <module>
from . import ty
  File "/root/tvm/python/tvm/relay/ty.py", line 26, in <module>
Any = _ffi_api.Any
AttributeError: module 'tvm.relay._ffi_api' has no attribute 'Any'

@SerenaC94 @hgt312 I just followed the steps mentioned here - Vitis-AI Integration — tvm 0.8.dev0 documentation

Tried with v0.7.0 branch too. Pops the same error.

root@pynq:/home/xilinx/tvm/python# python3 -c 'from tvm import relay'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/xilinx/tvm/python/tvm/relay/__init__.py", line 23, in <module>
from . import ty
  File "/home/xilinx/tvm/python/tvm/relay/ty.py", line 26, in <module>
Any = _ffi_api.Any
AttributeError: module 'tvm.relay._ffi_api' has no attribute 'Any'

Then I noticed that “Any” variable is not used anywhere in the file (other than this creating/assigning instance) - /home/xilinx/tvm/python/tvm/relay/ty.py - Commented this line and tried to do “python3 -c ‘from tvm import relay’” but throws another error:

root@pynq:/home/xilinx/tvm/python# python3 -c 'from tvm import relay'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/xilinx/tvm/python/tvm/relay/__init__.py", line 29, in <module>
    from . import prelude
  File "/home/xilinx/tvm/python/tvm/relay/prelude.py", line 20, in <module>
    from tvm.relay.transform import ToANormalFormExpr
  File "/home/xilinx/tvm/python/tvm/relay/transform/__init__.py", line 20, in <module>
    from .transform import *
  File "/home/xilinx/tvm/python/tvm/relay/transform/transform.py", line 944, in <module>
    @function_pass(opt_level=1)
  File "/home/xilinx/tvm/python/tvm/relay/transform/transform.py", line 932, in create_function_pass
    info = tvm.transform.PassInfo(opt_level, fname, required)
  File "/home/xilinx/tvm/python/tvm/ir/transform.py", line 49, in __init__
    self.__init_handle_by_constructor__(_ffi_transform_api.PassInfo, opt_level, name, required)
AttributeError: module 'tvm.ir._ffi_transform_api' has no attribute 'PassInfo'

Any suggestions?

Hello! In the process of building TVM0.8, I also met the same problem. Could you please tell me how to solve it? Thanks!

Please try to build the tvm from scratch and reinstall the python binding(if you used the setup.py)

Thank you very much. It has been successfully installed a week ago through “install from source”.I am a senior student. I used to do the development related to Xilinx FPGA, but I found it very difficult to learn it recently.Many functions have changed in version 0.8, and it’s a bit hard to find the exact functions used in the 0.6 code online.Can I still find the Tutorial for 0.6dev?Thanks!

I build on xilinx vck190 follow Vitis AI Integration — tvm 0.10.dev0 documentation, but error of

Traceback (most recent call last):
  File "/home/root/demo/demo.py", line 5, in <module>
    import tvm.relay as relay
  File "/home/root/tvm/tvm/python/tvm/relay/__init__.py", line 23, in <module>
    from . import ty
  File "/home/root/tvm/tvm/python/tvm/relay/ty.py", line 26, in <module>
    Any = _ffi_api.Any
AttributeError: module 'tvm.relay._ffi_api' has no attribute 'Any'

and I rebuild tvm_runtime again and again, but failed.

Any one can help me.