V-aerus opened a new pull request, #19937:
URL: https://github.com/apache/tvm/pull/19937
This PR fixes the PyTorch ExportedProgram importer lowering for
`torch.masked_select`.
Previously, `masked_select` lowered to:
- flatten data and mask
- `nonzero(mask_flat)`
- `squeeze(axis=[0])`
- `take(data_flat, indices)`
However, the result of `R.nonzero` only carried rank information. The
following `R.squeeze` over the dynamic nonzero output could remain unhandled
during build/VM execution.
This PR inserts a `match_cast` after `R.nonzero` using the exported output
metadata, preserving the dynamic selected-length dimension before `squeeze`.
A numerical regression test is also added to cover:
PyTorch eager -> torch.export -> Relax import -> build -> VM run -> output
comparison
Testing:
- `python -m pytest -q
tests/python/relax/test_frontend_from_exported_program.py -k 'masked_select'`
--
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]