[Docs] Add DLight and MetaSchedule deep-dive instructions#19356
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a new tutorial for MetaSchedule, TVM's search-based auto-tuning framework, covering advanced topics such as task inspection, selective operator tuning, and database management. A critical bug was identified in the model execution section where the iteration over model parameters was incorrect and would cause a runtime error.
| ex = tvm.compile(final_mod, target) | ||
| vm = relax.VirtualMachine(ex, tvm.cpu()) | ||
| data = tvm.runtime.tensor(np.random.rand(*input_shape).astype("float32")) | ||
| tvm_params = [tvm.runtime.tensor(np.random.rand(*p.shape).astype(p.dtype)) for _, p in params] |
There was a problem hiding this comment.
The params object returned by export_tvm is a list of relax.Constant objects. Iterating over it with for _, p in params] will cause a TypeError as it's not a list of tuples. To correctly iterate, you should use for p in params. Additionally, to access the shape and dtype of a relax.Constant, you must use p.data.shape and p.data.dtype respectively, as the tvm.runtime.NDArray is stored in the data attribute.
| tvm_params = [tvm.runtime.tensor(np.random.rand(*p.shape).astype(p.dtype)) for _, p in params] | |
| tvm_params = [tvm.runtime.tensor(np.random.rand(*p.data.shape).astype(p.data.dtype)) for p in params] |
This pr adds a instructions covering MetaSchedule and Flight usage in deep dive