Skip to content

refactor(compression): hoist numpy dtype map into tensor_type#3578

Open
rkuester wants to merge 1 commit into
tensorflow:mainfrom
rkuester:feat-tensor-type
Open

refactor(compression): hoist numpy dtype map into tensor_type#3578
rkuester wants to merge 1 commit into
tensorflow:mainfrom
rkuester:feat-tensor-type

Conversation

@rkuester
Copy link
Copy Markdown
Contributor

Add a tensor_type module that holds the single mapping from a TFLite
TensorType to a numpy dtype, and convert view.py to use it. The mapping
was inlined in view.py; centralizing it gives the compression tooling
one place to maintain as more callers need to read tensor buffers as
numpy arrays.

tensor_type.to_numpy() raises ValueError for types with no clean numpy
equivalent (STRING, RESOURCE, VARIANT, BFLOAT16, and the sub-byte
integer types) instead of silently returning a wrong dtype. Only types
with an unambiguous little-endian numpy representation are mapped.

BUG=part of #3256

@rkuester rkuester requested a review from a team as a code owner May 27, 2026 21:28
@rkuester rkuester added ci:full Triggers the comprehensive cross-platform test suite. ci:ready Triggers the basic TFLM test suite. labels May 27, 2026
@rkuester rkuester temporarily deployed to integration-test May 27, 2026 21:28 — with GitHub Actions Inactive
Comment thread tensorflow/lite/micro/compression/tensor_type_test.py
@rkuester rkuester removed the ci:ready Triggers the basic TFLM test suite. label May 27, 2026
Add a tensor_type module that holds the single mapping from a TFLite
TensorType to a numpy dtype, and convert view.py to use it. The mapping
was inlined in view.py; centralizing it gives the compression tooling
one place to maintain as more callers need to read tensor buffers as
numpy arrays.

tensor_type.to_numpy() raises ValueError for types with no clean numpy
equivalent (STRING, RESOURCE, VARIANT, BFLOAT16, and the sub-byte
integer types) instead of silently returning a wrong dtype. Only types
with an unambiguous little-endian numpy representation are mapped.

BUG=part of tensorflow#3256
@rkuester
Copy link
Copy Markdown
Contributor Author

Force-pushing a rebase onto latest main to clear a stuck merge. No code
changes. Applying ci:ready and ci:full together fired two concurrent CI
runs; the concurrency group cancelled one, which left a stale failing
tests-passed required check that blocks the merge. Rebasing onto a
clean commit gives a single fresh run.

@rkuester rkuester force-pushed the feat-tensor-type branch from 6c64e2f to 5a24d70 Compare May 27, 2026 22:48
@rkuester rkuester deployed to integration-test May 27, 2026 22:48 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:full Triggers the comprehensive cross-platform test suite.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants