Skip to content

[Relax][TFLite] Flatten FC input without keep_num_dims - #20784

Merged
tlopex merged 1 commit into
apache:mainfrom
guan404ming:fix-tflite-fc-keep-num-dims
Nov 18, 2026
Merged

tlopex merged 1 commit into
apache:mainfrom
guan404ming:fix-tflite-fc-keep-num-dims

Conversation

@guan404ming

@guan404ming guan404ming commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Why

  • TFLite FULLY_CONNECTED with keep_num_dims=false returns a 2-D output, but the Relax importer kept the input rank
  • A 3-D input therefore produced a 3-D result that did not match TFLite

How

  • Flatten inputs with rank above 2 to [-1, n_inputs] when keep_num_dims is false
  • Remove the resolved TODO about the keep_num_dims output shape
  • Add test_fully_connected_flattens_input_without_keep_num_dims, a structural IR test with a 3-D input

@guan404ming
guan404ming marked this pull request as ready for review October 17, 2026 22:10

@tlopex tlopex left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi @guan404ming Could you rebase this onto main? Thanks

@guan404ming
guan404ming force-pushed the fix-tflite-fc-keep-num-dims branch from 9081f61 to ac902c1 Compare November 18, 2026 08:04
@guan404ming

Copy link
Copy Markdown
Member Author

Thanks, rebased onto main

@tlopex
tlopex merged commit c84f80f into apache:main Nov 18, 2026
8 checks passed
@guan404ming

Copy link
Copy Markdown
Member Author

Thanks!

Netra-Srinivasan-McW pushed a commit to Netra-Srinivasan-McW/tvm-mcw that referenced this pull request Nov 20, 2026
## Why

- TFLite `FULLY_CONNECTED` with `keep_num_dims=false` returns a 2-D
output, but the Relax importer kept the input rank
- A 3-D input therefore produced a 3-D result that did not match TFLite

## How

- Flatten inputs with rank above 2 to `[-1, n_inputs]` when
`keep_num_dims` is false
- Remove the resolved TODO about the `keep_num_dims` output shape
- Add `test_fully_connected_flattens_input_without_keep_num_dims`, a
structural IR test with a 3-D input
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.

2 participants