Repository navigation
Conversation
|
Addressed the CPU structural-IR regressions in 4923c2a without weakening or rewriting the existing expectations. The symbolic fallback was unnecessarily used even when every input extent was static or structurally identical to its aligned output extent. Such cases do not need runtime singleton checks. They now retain the original C++ fast path/IR; genuinely ambiguous extents still use the guarded indexing required by the numerical regression. Added two focused IR-preservation tests mirroring the affected broadcast shapes: (n,n)->(1,1,n,n) and (n,1,m)->(a,n,c,m). Both fail before this follow-up and pass afterward. All 25 targeted tests now pass, including the original LLVM/VM numerical cases. Ruff lint/format and diff checks pass. Local validation uses the existing-runtime compatibility harness documented above, not a complete latest-main build. The three complete CI test functions/full CPU suite still need the fresh CI run; the push has triggered it. |
Summary
Fixes #20873.
The constant-target Expand path reads every input extent through .value, which fails for symbolic extents. Preserve non-IntImm expressions, keep existing static dimension checks, and retain a symbolic input extent when the corresponding requested dimension is 1.
Import-only changes are insufficient: an unknown input extent can be 1 at runtime. The existing TOPI broadcast indices can then incorrectly read successive input rows/columns instead of index 0. Add a symbolic-input fallback to the Python broadcast_to wrapper that selects index 0 for runtime singleton dimensions. The existing C++ shape construction/checks are still invoked, and fully static inputs keep the original fast path. C++-only callers are unchanged.
This does not add a general runtime validator for arbitrary incompatible dynamic inputs, nor change the separate runtime-target Expand shape-merging path or singleton-to-zero static validation.
Regression tests
23 LLVM/Relax VM tests compare against ONNX Runtime and NumPy:
Initial tests before the frontend fix: 7 failed, 8 passed. A frontend-only change exposed incorrect runtime-singleton results, so the TOPI adjustment is necessary. Expanded final tests: 23 passed.
Ruff 0.12.3 lint/format and git diff --check passed.
Validation scope
Local validation loaded the main-based Expand class and complete TOPI broadcast module verbatim into an existing WSL Ubuntu 22.04 TVM 0.26 importer/runtime (Python 3.10). Compatibility mappings were needed for the tvm_tirx import name, GenericConst/IntImm type names, and constant.value versus constant.data. The old legalizer also captures its TE function at import time, so the harness rebound its broadcast_to legalization callback to the new function. These are local harness adaptations, not source rewrites or PR files.
Models were compiled for LLVM and executed. This is not a full latest-main build, and the complete existing TOPI suite has not been run.
Main-environment command: