[Relax][Frontend][TFLite] Add explicit operator marker handling#19824
[Relax][Frontend][TFLite] Add explicit operator marker handling#19824Aharrypotter wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds explicit handling for TFLite marker builtins (DELEGATE and PLACEHOLDER_FOR_GREATER_OP_CODES) in the Relax TFLite frontend, raising a clear OpNotImplemented error instead of failing silently or with a generic error. It also includes corresponding unit tests. The reviewer suggested adding a check to skip these tests if the installed tflite package version is older and does not define these operators, preventing potential test failures in those environments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| def test_operator_marker_unsupported(builtin_name): | ||
| """TFLite marker builtins report explicit unsupported diagnostics.""" | ||
| with pytest.raises(tvm.error.OpNotImplemented, match=f"TFLite operator marker {builtin_name}"): | ||
| _load_model_from_buffer(_build_tflite_operator_marker_model(builtin_name)) |
There was a problem hiding this comment.
To prevent test failures in environments with older versions of the tflite package (where DELEGATE or PLACEHOLDER_FOR_GREATER_OP_CODES might not be defined in _tfl_builtin_operator), we should check for their existence and skip the test if they are missing.
| def test_operator_marker_unsupported(builtin_name): | |
| """TFLite marker builtins report explicit unsupported diagnostics.""" | |
| with pytest.raises(tvm.error.OpNotImplemented, match=f"TFLite operator marker {builtin_name}"): | |
| _load_model_from_buffer(_build_tflite_operator_marker_model(builtin_name)) | |
| def test_operator_marker_unsupported(builtin_name): | |
| """TFLite marker builtins report explicit unsupported diagnostics.""" | |
| if not hasattr(_tfl_builtin_operator, builtin_name): | |
| pytest.skip(f"{builtin_name} is not supported by the installed tflite package version.") | |
| with pytest.raises(tvm.error.OpNotImplemented, match=f"TFLite operator marker {builtin_name}"): | |
| _load_model_from_buffer(_build_tflite_operator_marker_model(builtin_name)) |
Summary
This PR adds explicit Relax TFLite frontend handling for the TFLite builtin
operator markers from #19519 item H:
DELEGATEPLACEHOLDER_FOR_GREATER_OP_CODESThese builtins are TFLite marker / pseudo operators rather than ordinary tensor
operators. The frontend now recognizes them and raises a targeted
OpNotImplementeddiagnostic instead of falling through to a genericunsupported-operator path.
Design
DELEGATEmarks delegated TFLite subgraphs, andPLACEHOLDER_FOR_GREATER_OP_CODESis a schema compatibility placeholder. Theydo not have Relax tensor semantics to lower. This PR therefore keeps the
importer conservative:
convert_mapconvert_operator_markerguardThis makes the unsupported status intentional and discoverable without mapping
the markers to synthetic Relax ops.
Tests
The tests manually build minimal TFLite flatbuffers containing each marker
builtin and assert that import raises the targeted
OpNotImplemented.Local validation:
Result:
References