[Relax][Frontend][TFLite] Add BITCAST operator mapping#19466
[Relax][Frontend][TFLite] Add BITCAST operator mapping#19466tlopex merged 2 commits intoapache:mainfrom
Conversation
This PR adds TFLite frontend support for the BITCAST operator which reinterprets a tensor's bytes as a different dtype without converting the underlying data. The handler lowers BITCAST to relax.op.memory.view which aliases the input buffer with the new shape and dtype. Frontend regression tests cover same-width (float32 -> int32, uint8 -> int8), width-changing smaller (int32[3] -> int16[3, 2]), and width-changing larger (int16[5, 2] -> int32[5]). ` python -m pytest tests/python/relax/test_frontend_tflite.py -k bitcast -v ` Addresses the BITCAST item under apache#19412.
There was a problem hiding this comment.
Code Review
This pull request adds support for the BITCAST operator in the TFLite frontend, mapping it to relax.op.memory.view. The implementation includes validation for input/output tensor counts and ensures total byte sizes match, with comprehensive tests added for various data type and shape transformations. Feedback recommends using the to_int_list utility for shape conversion to maintain consistency with the existing codebase and prevent potential type mismatches.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@tlopex - Quick design check. Issue #19412 lists BITCAST and mentions needing a dedicated op. I went with If you'd prefer a first-class |
This PR adds TFLite frontend support for the BITCAST operator which reinterprets a tensor's bytes as a different dtype without converting the underlying data.
The handler lowers BITCAST to relax.op.memory.view which aliases the input buffer with the new shape and dtype.
Frontend tests cover same-width (float32 -> int32, uint8 -> int8), width-changing smaller (int32[3] -> int16[3, 2]), and width-changing larger (int16[5, 2] -> int32[5]).
python -m pytest tests/python/relax/test_frontend_tflite.py -k bitcast -vAddresses the BITCAST item under #19412.