[Docs] Add tvm.s_tir.analysis API reference page#19353
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a mechanism to resolve ambiguous cross-references in the documentation by defining module type preferences, specifically mapping 'tvm.s_tir' to 'tvm.tirx'. It also adds the 'tvm.s_tir.analysis' module to the Python API documentation. A review comment suggests refining the module prefix matching logic in 'docs/conf.py' to ensure that only intended modules and their sub-modules are matched, preventing potential false positives with similarly named modules.
| if modname.startswith(prefix): | ||
| preferred = [m for m in matches if m[0].startswith(preferred_mod + ".")] |
There was a problem hiding this comment.
The startswith checks on modname and m[0] are a bit too broad and could match modules that share a prefix but are not sub-modules (e.g., tvm.s_tir_extra would match tvm.s_tir). It's safer to check for an exact match or a trailing dot to ensure it only applies to the intended module and its sub-modules.
| if modname.startswith(prefix): | |
| preferred = [m for m in matches if m[0].startswith(preferred_mod + ".")] | |
| if modname == prefix or modname.startswith(prefix + "."): | |
| preferred = [m for m in matches if m[0] == preferred_mod or m[0].startswith(preferred_mod + ".")] |
This PR adds the API reference documentation for `tvm.s_tir.analysis`.
`tvm.s_tir.analysis` functions use Var in their type annotations, which
exists in both `tvm.tirx` and `tvm.relax`. The existing disambiguator
uses common module prefix to pick the right one, but `tvm.s_tir` shares
no prefix with either. The new `tvm_module_type_preference` mapping
tells the disambiguator to prefer `tvm.tirx` types for `tvm.s_tir.*`
modules.
This PR adds the API reference documentation for
tvm.s_tir.analysis.tvm.s_tir.analysisfunctions use Var in their type annotations, which exists in bothtvm.tirxandtvm.relax. The existing disambiguator uses common module prefix to pick the right one, buttvm.s_tirshares no prefix with either. The newtvm_module_type_preferencemapping tells the disambiguator to prefertvm.tirxtypes fortvm.s_tir.*modules.