Skip to content

Raise ArgumentError for multiple :auto dimensions in reshape - #1819

Merged
polvalente merged 1 commit into
elixir-nx:mainfrom
blasphemetheus:fix/reshape-auto-error
Aug 17, 2026
Merged

Raise ArgumentError for multiple :auto dimensions in reshape#1819
polvalente merged 1 commit into
elixir-nx:mainfrom
blasphemetheus:fix/reshape-auto-error

Conversation

@blasphemetheus

Copy link
Copy Markdown
Contributor

Nx.reshape with more than one :auto dimension leaked a bare ArithmeticError: after resolving the first :auto, Tuple.product multiplied by the second :auto atom.

Nx.reshape(Nx.iota({12}), {:auto, :auto})
# before: ** (ArithmeticError) bad argument in arithmetic expression
# after:  ** (ArgumentError) only a single :auto dimension is allowed in reshape, got: {:auto, :auto}

🤖 Generated with Claude Code

Nx.reshape with more than one :auto leaked a bare ArithmeticError:
after resolving the first :auto, Tuple.product multiplied by the
second :auto atom. Now raises a descriptive ArgumentError.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@blasphemetheus

Copy link
Copy Markdown
Contributor Author

this one is more opinionated, but covers a uncovered and unintentional error that would be confusing to run into in the wild

@polvalente polvalente left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth a pass in Nx.revectorize :target_shape

@polvalente
polvalente merged commit 2c79776 into elixir-nx:main Aug 17, 2026
9 checks passed
@blasphemetheus
blasphemetheus deleted the fix/reshape-auto-error 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