tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[Tracking Issue][TFLite] Remaining builtin operator coverage beyond #19412

Open tlopex opened this issue 6 months ago • 27 comments

The Relax TFLite frontend has made good progress recently:

  • #18971 tracks unit test coverage for already-supported non-quantized operators.
  • #19412 tracks a first batch of missing or partial operators that are good-first-issue or medium-sized frontend tasks.

This issue tracks the remaining larger TFLite builtin operator coverage that is not already well-covered by those two issues.

The goal is to make the remaining gaps visible, split them by complexity, and let contributors pick coherent operator families instead of one-off unsupported ops.

Scope

This issue covers remaining TFLite builtin operators that fall into larger semantic groups. This issue does not track quantized model support as a whole; that should be tracked separately.

A. Sequence / recurrent model operators

  • [x] RNN
  • [x] LSTM
  • [x] SVDF
  • [x] UNIDIRECTIONAL_SEQUENCE_RNN
  • [x] UNIDIRECTIONAL_SEQUENCE_LSTM
  • [x] BIDIRECTIONAL_SEQUENCE_RNN
  • [x] BIDIRECTIONAL_SEQUENCE_LSTM

B. 3D convolution family

  • [x] CONV_3D
  • [x] CONV_3D_TRANSPOSE

C. FFT / complex operators

  • [x] RFFT2D
  • [x] REAL
  • [x] IMAG
  • [x] COMPLEX_ABS

D. Sparse embedding operators

  • [x] EMBEDDING_LOOKUP_SPARSE
  • [x] HASHTABLE_LOOKUP

E. Window reduction

  • [x] REDUCE_WINDOW

F. Control flow / multi-subgraph operators

  • [x] IF
  • [x] WHILE
  • [x] CALL
  • [x] CALL_ONCE

G. Resource / variable / hashtable operators

  • [x] VAR_HANDLE
  • [x] READ_VARIABLE
  • [x] ASSIGN_VARIABLE
  • [x] HASHTABLE
  • [x] HASHTABLE_FIND
  • [x] HASHTABLE_IMPORT
  • [x] HASHTABLE_SIZE

H. Operator markers

  • [x] DELEGATE
  • [x] PLACEHOLDER_FOR_GREATER_OP_CODES

I. StableHLO operators in TFLite

  • [x] STABLEHLO_ABS
  • [x] STABLEHLO_ADD
  • [x] STABLEHLO_AND
  • [x] STABLEHLO_BROADCAST_IN_DIM
  • [x] STABLEHLO_CBRT
  • [x] STABLEHLO_CLAMP
  • [x] STABLEHLO_COMPARE
  • [x] STABLEHLO_COMPOSITE
  • [x] STABLEHLO_CONCATENATE
  • [x] STABLEHLO_CONVERT
  • [x] STABLEHLO_CONVOLUTION
  • [x] STABLEHLO_COSINE
  • [x] STABLEHLO_CUSTOM_CALL
  • [x] STABLEHLO_DIVIDE
  • [x] STABLEHLO_DOT_GENERAL
  • [x] STABLEHLO_DYNAMIC_SLICE
  • [x] STABLEHLO_DYNAMIC_UPDATE_SLICE
  • [x] STABLEHLO_EXPONENTIAL
  • [x] STABLEHLO_FLOOR
  • [x] STABLEHLO_GATHER
  • [x] STABLEHLO_IOTA
  • [x] STABLEHLO_LOG
  • [x] STABLEHLO_LOGISTIC
  • [x] STABLEHLO_MAXIMUM
  • [x] STABLEHLO_MINIMUM
  • [x] STABLEHLO_MULTIPLY
  • [x] STABLEHLO_NEGATE
  • [x] STABLEHLO_OR
  • [x] STABLEHLO_PAD
  • [x] STABLEHLO_POWER
  • [x] STABLEHLO_REDUCE
  • [x] STABLEHLO_REDUCE_WINDOW
  • [x] STABLEHLO_REMAINDER
  • [x] STABLEHLO_RESHAPE
  • [x] STABLEHLO_RNG_BIT_GENERATOR
  • [x] STABLEHLO_RSQRT
  • [x] STABLEHLO_SCATTER
  • [x] STABLEHLO_SELECT
  • [x] STABLEHLO_SHIFT_LEFT
  • [x] STABLEHLO_SLICE
  • [x] STABLEHLO_SORT
  • [x] STABLEHLO_SUBTRACT
  • [x] STABLEHLO_TANH
  • [x] STABLEHLO_TRANSPOSE
  • [x] STABLEHLO_WHILE

Suggested contribution workflow

  1. Claim an item by commenting on this issue before starting, so we avoid duplicated work.
  2. Read a recent reference PR for handler + test style.
  3. Add the handler, register in convert_map (alphabetical within its region).
  4. Add a structural-equal test following the verify(TestClass, expected=None) pattern (test_frontend_tflite.py:56). Nightly-gated E2E activates automatically via CI_ENV_NIGHTLY.
  5. Tag the PR title [Relax][Frontend][TFLite].

References

  • #18971: supported non-quantized operator test coverage
  • #19412: first batch of missing / partial TFLite operator coverage
  • Relax TFLite frontend: python/tvm/relax/frontend/tflite/tflite_frontend.py
  • TFLite frontend tests: tests/python/relax/test_frontend_tflite.py

cc @leandron

tlopex avatar May 08 '26 16:05 tlopex

Hi @tlopex, I’d like to pick up the TFLite 3D convolution family in the Relax TFLite frontend (tracking issue #19519).

I’ll follow the existing frontend style by adding the handler(s), registering them in convert_map, and adding structural-equal tests in tests/python/relax/test_frontend_tflite.py.

To keep the PRs reviewable, I plan to start with CONV_3D first, then follow up with CONV_3D_TRANSPOSE in a separate PR if this direction looks reasonable.

weicheng-hsu avatar May 08 '26 16:05 weicheng-hsu

Hi @tlopex, I'd like to claim I. StableHLO operators in TFLite.

I'm very interested in StableHLO recently, especially because I'm currently learning JAX/XLA/StableHLO-related stacks. I'd like to take the full StableHLO-in-TFLite operator family and submit the implementation incrementally through multiple reviewable PRs.

I will start with a small subset first, add the corresponding Relax TFLite frontend handlers and structural-equal tests, then extend the coverage step by step.

Aharrypotter avatar May 08 '26 17:05 Aharrypotter

Hi @tlopex and @Aharrypotter, I’m interested in contributing to the StableHLO operator support in the Relax TFLite frontend.

Would it be okay if I work on:

STABLEHLO_RESHAPE STABLEHLO_TRANSPOSE STABLEHLO_SLICE

to help split the work and avoid overlap?

Mohxen avatar May 09 '26 14:05 Mohxen

Hi @tlopex and @Aharrypotter, I’m interested in contributing to the StableHLO operator support in the Relax TFLite frontend.

Would it be okay if I work on:

STABLEHLO_RESHAPE STABLEHLO_TRANSPOSE STABLEHLO_SLICE

to help split the work and avoid overlap?

Hi @Mohxen , yes, that works for me, and thanks for your interest!

I’m currently preparing a small initial PR for StableHLO-in-TFLite support, mainly to establish the reference pattern for the frontend handlers, convert_map registration, and structural-equal tests.

Would it be okay if I land that first batch before we split the remaining ops? Once it is merged, you could use it as a reference and pick up follow-up StableHLO ops. I think this would help avoid overlap and keep the implementation and test style consistent.

Aharrypotter avatar May 10 '26 08:05 Aharrypotter

Hi, @tlopex , I'd like to work on the TFLite builtin REDUCE_WINDOW item from #19519 (not STABLEHLO_REDUCE_WINDOW). I'll add the Relax TFLite frontend converter and tests, covering all ReduceWindowFunction modes.

THINKER-ONLY avatar May 12 '26 07:05 THINKER-ONLY

Hello @tlopex

I would like to pick the FFT / complex operators

raising a PR soon

fnhirwa avatar May 13 '26 23:05 fnhirwa

Hi @tlopex, I'd like to claim F. Control flow / multi-subgraph operators.

After working on the StableHLO-in-TFLite operator family, I'm interested in continuing with TFLite multi-subgraph/control-flow support. I'd like to take this family and implement it incrementally through multiple reviewable PRs.

I will start with a small initial PR to establish the basic import pattern and tests, then extend the coverage step by step.

Aharrypotter avatar May 18 '26 16:05 Aharrypotter

Hi @tlopex — I'd like to claim Group A: UNIDIRECTIONAL_SEQUENCE_RNN from this issue.

LudovicoYIN avatar May 25 '26 08:05 LudovicoYIN

Hi @tlopex, I'd like to claim G. Resource / variable / hashtable operators.

While working on the TFLite control-flow / multi-subgraph support in #19616, I noticed that CALL_ONCE is closely related to TFLite initialization subgraphs, especially variable and hash table initialization. I'd like to continue with this operator family and implement it incrementally through multiple reviewable PRs.

My plan is to start with the resource variable subset (VAR_HANDLE, ASSIGN_VARIABLE, READ_VARIABLE) to establish the basic resource-state import pattern, then follow up with the hashtable operators (HASHTABLE, HASHTABLE_IMPORT, HASHTABLE_FIND, HASHTABLE_SIZE).

Aharrypotter avatar May 27 '26 05:05 Aharrypotter

Hi @tlopex — I'd like to claim Group A: Sequence / recurrent model operators (RNN, LSTM, SVDF, UNIDIRECTIONAL_SEQUENCE_LSTM, BIDIRECTIONAL_SEQUENCE_RNN, BIDIRECTIONAL_SEQUENCE_LSTM). I'll start with RNN and submit incrementally.

LudovicoYIN avatar May 27 '26 09:05 LudovicoYIN

Hi @tlopex, I'd like to claim C. FFT / complex operators.

I plan to start with a small initial PR to check the Relax-side operator support and establish the frontend handler/test pattern, then extend the coverage step by step if the mapping is feasible.

Aharrypotter avatar May 31 '26 03:05 Aharrypotter

Hi @tlopex, I'd like to claim D. Legacy embedding / sparse embedding operators

LudovicoYIN avatar Jun 01 '26 03:06 LudovicoYIN

Hi @Mohxen, just a quick reminder about the remaining StableHLO-in-TFLite items from this tracking issue.

The initial StableHLO frontend pattern has now landed through the recent PRs.

The StableHLO section now looks mostly complete, and the remaining unchecked items are the ones you mentioned earlier:

  • STABLEHLO_RESHAPE
  • STABLEHLO_SLICE
  • STABLEHLO_TRANSPOSE

If you are still interested, this should be a good time to pick those up. The current implementations in python/tvm/relax/frontend/tflite/tflite_frontend.py and tests in tests/python/relax/test_frontend_tflite.py should provide the reference style for handler registration and structural-equal coverage.

Thanks for offering to help split the StableHLO work.

Aharrypotter avatar Jun 02 '26 06:06 Aharrypotter

Hi @Aharrypotter,

Thank you for the reminder and help. Yes, I am working on them. I will add support for STABLEHLO_RESHAPE, STABLEHLO_SLICE, and STABLEHLO_TRANSPOSE as soon as possible, following the current implementation style in tflite_frontend.py and the structural-equal test coverage in test_frontend_tflite.py.

Thanks again.

Mohxen avatar Jun 03 '26 14:06 Mohxen

Hi @tlopex, I would like to pick up the remaining operator marker items from group H:

  • DELEGATE
  • PLACEHOLDER_FOR_GREATER_OP_CODES

Since these are TFLite marker / pseudo builtins rather than regular tensor operators, I plan to add explicit Relax TFLite frontend handling and structural tests with clear diagnostics, rather than lowering them to Relax operators.

Aharrypotter avatar Jun 18 '26 03:06 Aharrypotter

Hi @tlopex, I audited the remaining D. Legacy embedding / sparse embedding items.

It looks like EMBEDDING_LOOKUP_SPARSE and HASHTABLE_LOOKUP have already landed, while the remaining unchecked items are:

  • CONCAT_EMBEDDINGS
  • LSH_PROJECTION
  • SKIP_GRAM

Since this part has not had follow-up PR activity for a while, I plan to pick up these remaining legacy embedding operators and send a focused PR. I will keep the PR scoped to explicit Relax TFLite frontend coverage and tests, with conservative diagnostics for cases that cannot be safely lowered yet.

Aharrypotter avatar Jun 22 '26 02:06 Aharrypotter

@Aharrypotter Thanks for the help! After considering it over, I think it's not necessary for us to support those legacy ops: CONCAT_EMBEDDINGS LSH_PROJECTION SKIP_GRAM DELEGATE PLACEHOLDER_FOR_GREATER_OP_CODES I'll also remove them from the list as well

tlopex avatar Jun 22 '26 03:06 tlopex

@Aharrypotter Thanks for the help! After considering it over, I think it's not necessary for us to support those legacy ops: CONCAT_EMBEDDINGS LSH_PROJECTION SKIP_GRAM DELEGATE PLACEHOLDER_FOR_GREATER_OP_CODES I'll also remove them from the list as well

Thanks for clarifying the scope. Since CONCAT_EMBEDDINGS, LSH_PROJECTION, and SKIP_GRAM are no longer needed in the tracking issue, I'll close the related PR rather than adding frontend coverage for these legacy ops.

Aharrypotter avatar Jun 22 '26 03:06 Aharrypotter

Hi @tlopex — I went back through the remaining unchecked boxes for G. Resource / variable / hashtable operators; with the PRs below, all of them are now fully addressed. Quick status:

G. Resource / variable / hashtable operators — all landed & tested

  • VAR_HANDLE, READ_VARIABLE, ASSIGN_VARIABLE, HASHTABLE, HASHTABLE_IMPORT, HASHTABLE_SIZE — Landed in #19639 (handles resource variable state capture and static hashtable metadata initialization inside the CALL_ONCE subgraph).
  • HASHTABLE_FIND — Landed in #19879 (supports static string -> int64 lookups on constant tables, fully lowered to a pure Relax tensor implementation using expand_dims, equal, argmax, take, and where to enable compile-time constant folding).

I think Section G can be checked off now. Please let me know if I've mischaracterized anything.

Aharrypotter avatar Jun 24 '26 11:06 Aharrypotter

Hi @tlopex , I noticed that in section I only STABLEHLO_RESHAPE, STABLEHLO_TRANSPOSE, and STABLEHLO_SLICE remain from this tracking issue. If no one is actively working on them, I'd like to work on these and submit PRs. Please let me know if that's okay.

nirdesh17 avatar Jun 27 '26 03:06 nirdesh17