dpctl.tensor.tensordot

dpctl.tensor.tensordot(x1, x2, axes=2)[source]

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

Parameters:
  • x1 (usm_ndarray) – first input array, expected to have numeric data type.

  • x2 (usm_ndarray) – second input array, expected to have numeric data type. Corresponding contracted axes of x1 and x2 must be equal.

  • axes (Union[int, Tuple[Sequence[int], Sequence[int]]) –

    number of axes to contract or explicit sequences of axes for x1 and x2, respectively. If axes is an integer equal to N, then the contraction is performed over last N axes of x1 and the first N axis of x2 in order. The size of each corresponding axis must match and must be non-negative.

    • if N equals 0, the result is the tensor outer product

    • if N equals 1, the result is the tensor dot product

    • if N equals 2, the result is the tensor double contraction (default).

    If axes is a tuple of two sequences (x1_axes, x2_axes), the first sequence applies to x1 and the second sequence applies to x2. Both sequences must have equal length, and each axis x1_axes[i] for x1 must have the same size as the respective axis x2_axes[i] for x2. Each sequence must consist of unique integers that specify valid axes for each respective array. For example, if x1 has rank N, a valid axis must reside on the half-open interval [-N, N).

Returns:

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

Return type:

usm_ndarray