`mlx_funcify_pad` forwarded `pad_width` straight to `mx.pad`, but the linker
typifies every input to `mx.array` while `mx.pad` takes an int or a list of
(before, after) int pairs, so no pad worked on this backend -- both
`test_mlx_pad[constant_default]` and `test_mlx_pad[edge]` were already red on
main.
Resolve a constant `pad_width` at funcify time, as the `Reshape` dispatch
does, since `mx.compile` forbids reading a traced array; fall back to a
runtime conversion otherwise, with an explicit `NotImplementedError` if the
value turns out not to be readable.
Same root cause as pymc-devs#2386 and the sort/argsort `axis` fix.
Closes #2392.
Motivation
mlx_funcify_pad forwarded pad_width straight to mx.pad, but the linker typifies every input to mx.array while mx.pad takes an int or a list of (before, after) int pairs, so no pad worked on this backend. test_mlx_pad[constant_default] and test_mlx_pad[edge] were already red on main.
Same root cause as #2386 and #2391.
Implementation
Resolve a Constant pad_width at funcify time, as the Reshape dispatch does — mx.compile is on by default and forbids reading a traced array. Fall back to a runtime conversion otherwise, raising NotImplementedError with an explanation if the value turns out not to be readable.
mx.pad also rejects a nested list of lists, so a 2-d spec is normalised to a list of tuples.
Tests
The two red tests pass now. Added test_mlx_pad_width_forms, covering scalar, single-pair and per-axis widths × constant and edge modes under the full "MLX" mode.
Full tests/link/mlx/ suite: no regressions.