mlx_funcify_Reshape forwards the shape input straight to mx.reshape, but the linker typifies every input to mx.array and mx.reshape wants a Python sequence of ints, so no reshape works on this backend at all.
import numpy as np
import pytensor
import pytensor.tensor as pt
x = pt.matrix("x", shape=(6, 4), dtype="float32")
xv = np.zeros((6, 4), dtype="float32")
print(pytensor.function([x], x.reshape((24,)), mode="CVM")(xv).shape) # (24,)
print(pytensor.function([x], x.reshape((24,)), mode="MLX")(xv).shape)
# TypeError: reshape(): incompatible function arguments
# Invoked with types: mlx.core.array, mlx.core.array
Potential fix (requires testing):
def reshape(x, shp):
return mx.reshape(x, tuple(shp.tolist()) if isinstance(shp, mx.array) else tuple(shp))
mlx_funcify_Reshapeforwards the shape input straight tomx.reshape, but the linker typifies every input tomx.arrayandmx.reshapewants a Python sequence of ints, so no reshape works on this backend at all.Potential fix (requires testing):