skcuda.linalg.mdot¶
-
skcuda.linalg.
mdot
(*args, **kwargs)[source]¶ Product of several matrices.
Computes the matrix product of several arrays of shapes.
Parameters: - b_gpu, .. (a_gpu,) – Arrays to multiply.
- handle (int) – CUBLAS context. If no context is specified, the default handle from skcuda.misc._global_cublas_handle is used.
Returns: c_gpu – Matrix product of a_gpu, b_gpu, etc.
Return type: Notes
The input matrices must all contain elements of the same data type.
Examples
>>> import pycuda.gpuarray as gpuarray >>> import pycuda.autoinit >>> import numpy as np >>> import skcuda.linalg as linalg >>> linalg.init() >>> a = np.asarray(np.random.rand(4, 2), np.float32) >>> b = np.asarray(np.random.rand(2, 2), np.float32) >>> c = np.asarray(np.random.rand(2, 2), np.float32) >>> a_gpu = gpuarray.to_gpu(a) >>> b_gpu = gpuarray.to_gpu(b) >>> c_gpu = gpuarray.to_gpu(c) >>> d_gpu = linalg.mdot(a_gpu, b_gpu, c_gpu) >>> np.allclose(np.dot(a, np.dot(b, c)), d_gpu.get()) True