Python wrappers
Public Python APIs implemented by this engine symbol.Compute the dot product of two vectors or the matrix product of two matrices, with autograd support for both cases.
Dispatches on rank:
- 1-D × 1-D — inner product
producing a scalar (shape
{}). Backed by Accelerate'scblas_*dotvia the element-wise multiply andreduce_sumbackend primitives. Backward node:Dot1DBackward(saves both operands).- 2-D × 2-D — matrix product .
Backed by
cblas_*gemm(Accelerate) on CPU,mlx::matmulon GPU. Backward node:Dot2DBackward(saves both operands).
- 2-D × 2-D — matrix product .
Backed by
Math
1-D case:
2-D case:
Shape
- 1-D:
a.shape[0] == b.shape[0]; output is rank-0. - 2-D:
a.shape[1] == b.shape[0]; output is .
References
NumPy numpy.dot semantics for the 1-D and 2-D cases.
See Also
matmul_op : N-D matmul with NumPy broadcasting on batch dims.
inner_op : Last-axis contraction (NumPy inner).
outer_op : 1-D × 1-D outer product.
Parameters
aTensorImplPtrFirst operand. Must be 1-D or 2-D.
bTensorImplPtrSecond operand. Must have the same rank as
a.Returns
TensorImplPtr- 1-D inputs → scalar tensor with shape
{}. - 2-D inputs of shape and → matrix of shape .
Raises
ShapeMismatchIf the contracted dimensions disagree (1-D length mismatch, or 2-D
a.shape[1] != b.shape[0]).NotImplementedIf either input has rank other than 1 or 2.
Notes
Unlike matmul_op this entry point uses AmpPolicy::KeepInput
— integer dot products are valid and must not be promoted silently.