[Relax][Frontend][TFLite] Add segment operator mappings#19491
[Relax][Frontend][TFLite] Add segment operator mappings#19491Aharrypotter wants to merge 1 commit intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for SEGMENT_SUM, UNSORTED_SEGMENT_MIN, and UNSORTED_SEGMENT_PROD operators in the TFLite frontend by lowering them to relax.op.scatter_nd. The implementation includes helper functions for identity base tensor creation and segment count calculation, along with corresponding unit tests. A syntax error was identified in the SEGMENT_SUM error handling logic where a closing parenthesis is incorrectly placed, which would lead to a failure during execution.
tlopex
left a comment
There was a problem hiding this comment.
Could you resolve the conflict so that we can merge it in?
|
I'll resolve the conflicts and update the PR shortly. |
cd79abd to
032b0db
Compare
|
Please take a look @tlopex. Fixed alphabetical ordering of operator mappings. |
Summary
This PR adds Relax TFLite frontend support for the following segment operators from #19412:
SEGMENT_SUMUNSORTED_SEGMENT_MINUNSORTED_SEGMENT_PRODThese operators are lowered through
relax.op.scatter_ndwith the corresponding reduction modes.Changes
TFLite Frontend
Add TFLite converter mappings for segment operators:
SEGMENT_SUM->scatter_nd(..., reduction="add")UNSORTED_SEGMENT_MIN->scatter_nd(..., reduction="min")UNSORTED_SEGMENT_PROD->scatter_nd(..., reduction="mul")Add shared segment lowering logic:
segment_idsinto scatter indices viaexpand_dims.num_segmentsor constantsegment_ids.Tests
Add TFLite frontend tests for:
test_segment_sumtest_unsorted_segment_mintest_unsorted_segment_prodEach test verifies the imported Relax IR lowers to
R.scatter_ndwith the expected reduction mode and base tensor initialization.Testing
All targeted tests pass:
References