tandede opened a new pull request, #20161:
URL: https://github.com/apache/tvm/pull/20161

   ONNX Reshape uses zero entries to copy the corresponding input dimension by 
default. The Relax importer currently constant-folds those shapes through NumPy 
without applying that rule, so a valid shape such as `[0, 3]` fails for a `(2, 
3)` tensor. Conversely, when `allowzero=1`, passing the zero through 
`relax.op.reshape` invokes Relax's own zero-copy convention instead of 
preserving the literal zero dimension.
   
   This change normalizes copied dimensions before constant folding when 
`allowzero` is disabled. When it is enabled, the shape tensor is materialized 
as a symbolic `ShapeExpr`, preserving literal zero dimensions without applying 
Relax's zero-copy shortcut.
   
   The regression tests cover both the default all-constant path and an 
executable `allowzero=1` model with a `(0, 2)` output.
   
   Fixes #20151
   
   Testing:
   
   ```
   pre-commit run --files python/tvm/relax/frontend/onnx/onnx_frontend.py 
tests/python/relax/test_frontend_onnx.py
   pytest -q tests/python/relax/test_frontend_onnx.py -k reshape
   pytest -q -n 4 tests/python/relax/test_frontend_onnx.py -k 'not 
test_clip_v13'
   ```
   
   The first two commands pass, and the broad run reports 493 passed, 9 
skipped, and 4 xfailed. Running the entire file also reports three 
`test_clip_v13` failures that reproduce unchanged on a clean `main` worktree in 
the same environment.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to