vvchernov opened a new pull request, #13596:
URL: https://github.com/apache/tvm/pull/13596
I investigated TIR kernel tuning by meta-scheduler and prepared for it the
python script with minimal imports from tvm.
There is sketch of my code:
```
import tvm
from tvm import meta_schedule as ms
from tvm.script import tir as T
@tvm.script.ir_module
class MyModule:
@T.prim_func
def main(...):
...
if __name__ == "__main__":
# params init
...
database = ms.database.JSONDatabase(
workload_path,
record_path,
work_dir=work_dir,
module_equality="ignore-ndarray",
)
ms.tir_integration.tune_tir(
mod=MyModule,
target=target,
work_dir=work_dir,
max_trials_global=trials_number,
database=database,
strategy="replay-trace",
)
```
But it has failed due to
[check](https://github.com/apache/tvm/blob/main/src/meta_schedule/space_generator/space_generator.cc#L28)
on native side of space generator. It tried to get packed func from
tvm.topi.x86.utils.target_has_vnni, but it is not registrated in my case.
Of course, the simplest fix is to add `from tvm.topi.x86.utils import
target_has_vnni` or `from tvm import topi` or `from tvm import relay` to python
tuning script. But as a client of TIR and meta scheduler high-level API I do
not need to know internal context. As result I've fixed it inside TVM.
The main fix is `from tvm import relay` in ms.relay_integration module. I
should note that it does it by its-self if TYPE_CHECKING=True (but looks like
it always False). Other code is related to hidding `from tvm.meta_schedule
import is_meta_schedule_enabled` due to circular python imports.
--
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]