Implementing kernel
C++ engine symbols that back this Python API.Generalized tensor contraction over arbitrary axes.
Contracts a and b along the axes specified by dims, generalizing
matrix multiplication to higher-rank tensors. dims may be:
- an
intN— contract the lastNaxes ofawith the firstNaxes ofb; - a pair of axis lists
[[a_axes], [b_axes]]— contract the listed axes ofaagainst the listed axes ofbpairwise.
Parameters
Returns
TensorContracted result whose remaining axes are the un-contracted axes of a
followed by those of b.
Notes
Mathematical definition for axis lists :
where denotes the axes not contracted. Equivalent to a suitable
permutation followed by matmul and a reshape.
Examples
>>> import lucid
>>> a = lucid.zeros((3, 4, 5))
>>> b = lucid.zeros((4, 5, 2))
>>> lucid.tensordot(a, b, dims=2).shape
(3, 2)