Skip to content

Implement Pad::vmap to replace NYI stub#3304

Merged
angeloskath merged 2 commits intoml-explore:mainfrom
Aristide021:pad-vmap
Mar 24, 2026
Merged

Implement Pad::vmap to replace NYI stub#3304
angeloskath merged 2 commits intoml-explore:mainfrom
Aristide021:pad-vmap

Conversation

@Aristide021
Copy link
Copy Markdown
Contributor

Description
Implements Pad::vmap and removes the NYI path in mlx/primitives.cpp.

Changes

  • Implement Pad::vmap in core.
  • Remap pad axes when vmapping over the input axis (including negative pad axes).
  • Keep in_axes=(0, None) behavior for scalar constant_values.
  • Reject vmapping over the pad value (axes[1] >= 0) with invalid_argument (Python ValueError).
  • Add mx.pad vmap coverage in python/tests/test_vmap.py.

Tests added

  • in_axes=0
  • in_axes=1
  • in_axes=-1, out_axes=-1
  • nested vmap
  • in_axes=(0, None) for pad value
  • mapped pad value raises ValueError

No change to existing pad semantics outside vmap support.
Closes the NYI stub at mlx/primitives.cpp:3234.

@angeloskath angeloskath merged commit 81530c2 into ml-explore:main Mar 24, 2026
16 checks passed
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