Repository navigation
fix: validate output signatures in LookupTableExportOp to prevent crash on dtype mismatch - #125856
Merged
copybara-service[bot] merged 1 commit intoSep 25, 2026
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces signature verification to the LookupTableExportOp kernel in lookup_table_op.cc to ensure that the input and output data types match the lookup table's key and value types. It also adds a unit test testExportSignatureMismatch in lookup_ops_test.py to verify that an error is raised when there is a signature mismatch. I have no feedback to provide as the implementation is correct and includes appropriate test coverage.
dianatofficial
left a comment
There was a problem hiding this comment.
LGTM! Code changes are clean and well-structured.
dmiltr3
approved these changes
Aug 24, 2026
…sh on dtype mismatch
adi-IL
force-pushed
the
fix/lookup-table-export-signature-mismatch
branch
from
September 15, 2026 18:38
fdcf992 to
c3bf3b3
Compare
dmiltr3
approved these changes
Sep 16, 2026
dmiltr3
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Internal presubmit tests passed successfully.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling
tf.raw_ops.LookupTableExportortf.raw_ops.LookupTableExportV2on a table with incompatible output key or value dtypes (for example, exporting anint64key/valueStaticHashTablewhile requestingtf.stringkeys and values) causes a fatal check failure abort:Root cause
In
tensorflow/core/kernels/lookup_table_op.cc, operations likeLookupTableFindOp,LookupTableInsertOp, andLookupTableImportOpcallctx->MatchSignature(...)to validate that the op's input and output dtypes match the underlying table'skey_dtype()andvalue_dtype().LookupTableExportOpwas missing this signature check. It directly invokedtable->ExportValues(ctx), which allocates the output tensors using the table's internalkey_dtype()andvalue_dtype(). WhenTkeysorTvaluesspecified in the Op definition differed from the table's types,OpKernelContext::allocate_outputhit a hardCHECK_EQassertion on the output type mismatch and terminated the process.Fix
Added
ctx->MatchSignature(expected_inputs, expected_outputs)inLookupTableExportOp::Computematching the pattern used by the neighboring lookup table kernels. When a dtype mismatch occurs, it now returns a standardInvalidArgumentErrorrather than aborting.Testing
testExportSignatureMismatchtoStaticHashTableTestintensorflow/python/kernel_tests/data_structures/lookup_ops_test.py, verifying that exporting with mismatchedTkeys/TvaluesraisesInvalidArgumentErrorinstead of terminating the process.python3 -m py_compile.Fixes #125503.