public void CopyTo(CudaMatrixFloat result) { if (result == null) { return; } IntPtr handle = cuBLAS.Create_v2(); cuBLAS.Scopy_v2( handle, Count, _DevicePointer, 1 , result._DevicePointer, 1 ); cuBLAS.Destroy_v2(handle); }
public void Mul(float value, CudaMatrixFloat result) { if (result == null) { return; } IntPtr handle = cuBLAS.Create_v2(); cuBLAS.Sscal_v2( handle, _Rows * _Cols, value, _DevicePointer, 1 ); cuBLAS.Destroy_v2(handle); }
public void Mul(CudaMatrixFloat matrix, CudaMatrixFloat result) { if (matrix == null || result == null) { return; } IntPtr handle = cuBLAS.Create_v2(); cuBLAS.Sdgmm( handle, cublasSideMode.CUBLAS_SIDE_LEFT, _Rows, _Cols, _DevicePointer, _Rows, matrix._DevicePointer, _Rows, result._DevicePointer, _Rows ); cuBLAS.Destroy_v2(handle); }
public void Add(float value, CudaMatrixFloat result) { if (result == null) { return; } if (_Module == null) { throw new CudaException("module is not initialized."); } CallMethod( _Module, "matrixAdd", _Cols, _Rows, _DevicePointer, result._DevicePointer, value, _Cols, _Rows ); }
public static CudaMatrixFloat FromByteArray(byte[] bytes) { if (bytes == null || bytes.Length < 12) { return(null); } int intSize = sizeof(int); int intSize2 = intSize * 2; int[] matrixSize = new int[2]; float[] data = new float[(bytes.Length - intSize2) / ItemSize]; Buffer.BlockCopy(bytes, 0, matrixSize, 0, intSize2); Buffer.BlockCopy(bytes, intSize2, data, 0, bytes.Length - intSize2); int rows = matrixSize[0]; int cols = matrixSize[1]; CudaMatrixFloat matrix = new CudaMatrixFloat(rows, cols); matrix.SetDeviceMemory(matrix._DevicePointer, data); return(matrix); }
public void Dot(CudaMatrixFloat matrix, CudaMatrixFloat result) { if (matrix == null || result == null) { return; } IntPtr handle = cuBLAS.Create_v2(); cuBLAS.Sgemm_v2( handle, cublasOperation.CUBLAS_OP_N, cublasOperation.CUBLAS_OP_N, _Rows, matrix._Cols, _Cols, 1f, _DevicePointer, _Rows, matrix._DevicePointer, matrix._Rows, 1f, result._DevicePointer, _Rows ); cuBLAS.Destroy_v2(handle); }