MasterJH5574 opened a new pull request, #14033: URL: https://github.com/apache/tvm/pull/14033
Prior to this PR, `python/tvm/script/__init__.py` imports both tir and relax submodules. This leads to the phenomenum that when people does ```python from tvm.script import tir as T ``` , the relax submodule will be implicitly visited by `__init__.py` as well. Since TIR does not rely on Relax, it is good not to import both of them at the same time. (This can prevent cyclic imports sometimes.) This PR does this decoupling by introducing two files * `python/tvm/script/relax.py` * `python/tvm/script/tir.py` and removing the imports from `python/tvm/script/__init__.py` and `python/tvm/script/parser/__init__.py`. With this change, we force people to manually do `from tvm.script import tir` and `from tvm.script import relax` to use TVMScript parser, which is right our conventional way. --- To elabore a bit more on the cyclic import: With #14029, submodule `relax.transform` will import topi to register the legalization functions for each operators into the op registry. Module topi imports the TVMScript parser of TIR, in `python/tvm/topi/arm_cpu.py`. As mentioned above, the previous behavior is when importing TIR parser, the submodule `tvm.script.parser.relax` is also visited and initialized, and thereby brings the risk of cyclic import. Since the TOPI side only needs TIR parser, we don’t need to import the Relax parser. By decoupling the import of TIR and Relax in module `tvm.script` can prevent the cyclic dependency. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
