dpnp.linalg.multi_dot

dpnp.linalg.multi_dot(arrays, *, out=None)[source]

Compute the dot product of two or more arrays in a single function call.

For full documentation refer to numpy.linalg.multi_dot.

Parameters:
  • arrays (sequence of dpnp.ndarray or usm_ndarray) -- If the first argument is 1-D it is treated as row vector. If the last argument is 1-D it is treated as column vector. The other arguments must be 2-D.

  • out ({None, dpnp.ndarray, usm_ndarray}, optional) -- Output argument. This must have the exact kind that would be returned if it was not used. In particular, it must have the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot(a, b). If these conditions are not met, an exception is raised, instead of attempting to be flexible. Default: None.

Returns:

out -- Returns the dot product of the supplied arrays.

Return type:

dpnp.ndarray

See also

dpnp.dot

Returns the dot product of two arrays.

dpnp.inner

Returns the inner product of two arrays.

Examples

>>> import dpnp as np
>>> from dpnp.linalg import multi_dot
>>> A = np.random.random((10000, 100))
>>> B = np.random.random((100, 1000))
>>> C = np.random.random((1000, 5))
>>> D = np.random.random((5, 333))

the actual dot multiplication

>>> multi_dot([A, B, C, D]).shape
(10000, 333)

instead of

>>> np.dot(np.dot(np.dot(A, B), C), D).shape
(10000, 333)

or

>>> A.dot(B).dot(C).dot(D).shape
(10000, 333)