tensordot — Python array API standard 2024.12 documentation (original) (raw)

tensordot(x1: array, x2: array, /, *, axes: int | Tuple[Sequence[int], Sequence[int]] = 2) → array

Returns a tensor contraction of x1 and x2 over specific axes.

Note

The tensordot function corresponds to the generalized matrix product.

Parameters:

Note

If either x1 or x2 has a complex floating-point data type, neither argument must be complex-conjugated or transposed. If conjugation and/or transposition is desired, these operations should be explicitly performed prior to computing the generalized matrix product.

Returns:

out (array) – an array containing the tensor contraction whose shape consists of the non-contracted axes (dimensions) of the first array x1, followed by the non-contracted axes (dimensions) of the second array x2. The returned array must have a data type determined by Type Promotion Rules.

Notes

Changed in version 2022.12: Added complex data type support.

Changed in version 2023.12: Allow negative axes.