jack-k737 opened a new pull request, #20405:
URL: https://github.com/apache/tvm/pull/20405

   ## Problem
   
   PyTorch dtype promotion depends on tensor rank. For example, a dimensioned 
`float32` tensor combined with a zero-dimensional `float64` tensor remains 
`float32`. The Torch importer used `torch.promote_types`, which ignored this 
distinction and incorrectly cast the result to `float64`. This could later make 
operators such as `where` fail because their input dtypes no longer matched.
   
   ## Changes
   
   - Use `torch.result_type` on meta tensors to reproduce rank-aware PyTorch 
promotion without allocating data.
   - Share operand dtype alignment with the division converter.
   - Reject unknown-rank combinations only when their possible rank categories 
produce different dtypes.
   - Add regressions for both operand orders, scalar and dimensioned operands, 
mixed numeric categories, unknown ranks, and a lifted double scalar feeding 
division then `where`.
   
   ## Testing
   
   - `python -m pytest 
tests/python/relax/test_frontend_from_exported_program.py -k 
'binary_dtype_promotion_rank or binary_dtype_promotion_unknown_rank or 
div_zero_dim_double_then_where' -q` (36 passed)
   - `pre-commit run --files 
python/tvm/relax/frontend/torch/base_fx_graph_translator.py 
tests/python/relax/test_frontend_from_exported_program.py`
   


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