Skip to content

[Relax][TFLite] Add gather frontend expected IRModule tests#19516

Open
weicheng-hsu wants to merge 1 commit intoapache:mainfrom
weicheng-hsu:relax/tflite-test-gather
Open

[Relax][TFLite] Add gather frontend expected IRModule tests#19516
weicheng-hsu wants to merge 1 commit intoapache:mainfrom
weicheng-hsu:relax/tflite-test-gather

Conversation

@weicheng-hsu
Copy link
Copy Markdown

@weicheng-hsu weicheng-hsu commented May 7, 2026

This adds explicit Expected IRModule coverage for TFLite GATHER and GATHER_ND frontend conversion.

GATHER_ND uses Relax gather_nd with int64 indices, so the frontend now casts int32 TFLite indices to int64 before emitting the Relax op. This keeps the generated module well-typed and matches the expected Relax IR.

Testing:

  • python -m pytest tests/python/relax/test_frontend_tflite.py -k "gather"

related to #18971

This adds explicit Expected IRModule coverage for TFLite GATHER and GATHER_ND frontend conversion.

GATHER_ND uses Relax gather_nd with int64 indices, so the frontend now casts int32 TFLite indices to int64 before emitting the Relax op. This keeps the generated module well-typed and matches the expected Relax IR.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the TFLite frontend in Relax to cast gather_nd indices to int64 if they are provided as int32, satisfying the requirements of the Relax gather_nd operator. Additionally, new test cases for gather and gather_nd have been added. The reviewer suggests extending these tests to cover both int32 and int64 indices for both operators to ensure comprehensive coverage.

verify(ReverseV2, Expected)


def test_gather():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test covers gather with int64 indices. For completeness, it would be beneficial to also add a test case for int32 indices, as TFLite's GATHER op supports both int32 and int64 for indices.

verify(Gather, Expected)


def test_gather_nd():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This test covers gather_nd with int32 indices, which is great for verifying the change in this PR. To make the test coverage for this operator more complete, could you also add a test case for int64 indices? This would ensure the int64 path is not broken by future changes and remains tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant