Skip to content

Fix inspect crash on sub-byte integer tensors - #1818

Merged
polvalente merged 1 commit into
elixir-nx:mainfrom
blasphemetheus:fix/inspect-sub-byte
Aug 17, 2026
Merged

Fix inspect crash on sub-byte integer tensors#1818
polvalente merged 1 commit into
elixir-nx:mainfrom
blasphemetheus:fix/inspect-sub-byte

Conversation

@blasphemetheus

Copy link
Copy Markdown
Contributor

Nx.Backend's inspect chunking used tail::binary in the :s/:u branches while the float branch already correctly used tail::bitstring — so IO.inspect on any u2/u4/s2/s4 tensor raised MatchError once the remaining data was not byte-aligned:

IO.inspect(Nx.tensor([1, 2, 3], type: {:u, 2}))
# ** (MatchError) no match of right hand side value ...

Two-character fix per branch. Since Nx.Backend.inspect is the shared implementation, this also fixes Torchx sub-byte tensors.

Regression test: exact inspect renderings for u2 and s2 tensors.

🤖 Generated with Claude Code

Nx.Backend's inspect chunking used tail::binary in the :s/:u branches
(the float branch already used tail::bitstring), so IO.inspect on any
u2/u4/s2/s4 tensor raised MatchError once the remaining data was not
byte-aligned. This is the shared inspect implementation, so the fix
also covers Torchx.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@polvalente
polvalente merged commit 849a52b into elixir-nx:main Aug 17, 2026
9 checks passed
@blasphemetheus
blasphemetheus deleted the fix/inspect-sub-byte branch August 17, 2026 17:49
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