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

   ### Motivation
   
   `torch.logical_or` and `torch.logical_xor` accept input tensors of any dtype
   (treating any nonzero element as `True`) and always return a `bool` tensor.
   
   Neither op was handled by the PyTorch frontend. The ExportedProgram frontend 
did
   not register `logical_or.default` / `logical_xor.default`, and the FX 
frontend
   did not register `logical_or` / `logical_xor`, so importing a model that uses
   either op failed early with `Unsupported function types`.
   
   This follows up on #19679 (`logical_and`) and addresses the explicit question
   raised in #19743: whether `logical_or` and `logical_xor` need the same 
handling.
   
   ### Changes
   
   - Add shared `_logical_or` and `_logical_xor` converters in 
`BaseFXGraphImporter`
     that cast non-bool operands to `bool` before applying 
`relax.op.logical_or` /
     `relax.op.logical_xor`. Bool operands are passed through unchanged (no
     redundant cast).
   - Register `logical_or.default` / `logical_xor.default` (ExportedProgram) and
     `logical_or` / `logical_xor` (FX), matching the existing `logical_and`
     converter.
   - Add standalone `test_logical_or` and `test_logical_xor` to both the FX and
     ExportedProgram test suites, asserting the corrected IR (`astype` to bool 
on
     each operand, then the logical op, producing a `bool` output).
   
   ### Notes
   
   The cast to `bool` lowers to an elementwise nonzero test, so it matches
   PyTorch's "nonzero is True" semantics for float, integer, and NaN inputs.
   


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