Python wrappers
Public Python APIs implemented by this engine symbol.Compute the generalised inner product of and by contracting their last axes (NumPy inner semantics).
For rank- and rank- inputs whose last dims agree in size, the output preserves all leading-of-A dims followed by all leading-of-B dims, with the shared last axis summed out.
Math
General contraction over the trailing axis ():
2-D × 2-D specialisation:
Shape
a.shape[-1] == b.shape[-1]is required.- Output shape concatenates the all-but-last dims of each input.
References
NumPy numpy.inner (which Lucid mirrors).
See Also
dot_op : 1-D × 1-D / 2-D × 2-D specialised dispatch. matmul_op : Standard matmul with NumPy batch broadcasting. outer_op : 1-D outer product (the rank-1 "anti-inner"). einsum_op : The lowering target for the gradient-tracked path.
Parameters
aTensorImplPtrbTensorImplPtra.shape[-1].Returns
TensorImplPtrOutput with shape a.shape[:-1] + b.shape[:-1]. When both inputs are 1-D the result is a scalar (shape {}).
Raises
ShapeMismatchNotes
When gradient tracking is enabled this op is lowered to einsum_op
with a pattern produced by inner_einsum_pattern (free axes of
use letters a..o, free axes of use p..y, contracted axis
is z). The einsum backward pass handles autograd, so this op has
no dedicated backward node.
On the GPU stream the output shape is read back from the MLX array after the kernel returns to absorb any scalar-squeeze MLX may perform.
Examples
// a: [3, 5], b: [2, 5] → out: [3, 2]
// out[i, j] = sum_k a[i, k] * b[j, k]