Backends/SiaNet.Backend.TensorSharp/Cpu/MatrixMultiplication.cs
/// <summary>
/// Runs the m v double.
/// </summary>
/// <param name="result">The result.</param>
/// <param name="lhs">The LHS.</param>
/// <param name="rhs">The RHS.</param>
/// <exception cref="ArgumentException">lhs must be contiguous in the last dimension</exception>
Runs the m v double.
Runs the m v double .
private static void Run_M_V_double(NDArray result, NDArray lhs, NDArray rhs)
        {
            if (lhs.Strides[1] != 1) throw new ArgumentException("lhs must be contiguous in the last dimension");
            unsafe
            {
                var resultPtr = (double*)CpuNativeHelpers.GetBufferStart(result);
                var lhsPtr = (double*)CpuNativeHelpers.GetBufferStart(lhs);
                var rhsPtr = (double*)CpuNativeHelpers.GetBufferStart(rhs);
                byte trans = (byte)'t';
                int m = (int)rhs.Shape[1];
                int n = (int)lhs.Shape[0];
                int lda = (int)rhs.Strides[0];
                int ldb = (int)lhs.Strides[0];
                int ldc = (int)result.Strides[0];
                double alpha = 1;
                double beta = 0;
                OpenBlasNative.dgemv_(&trans, &m, &n, &alpha, rhsPtr, &lda, lhsPtr, &ldb, &beta, resultPtr, &ldc);
            }
        }
private static void Run_M_V_double ( NDArray result , NDArray lhs , NDArray rhs ) { if ( lhs . Strides [ 1 ] != 1 ) throw new ArgumentException ( " " ) ; unsafe { var resultPtr = ( double * ) CpuNativeHelpers . GetBufferStart ( result ) ; var lhsPtr = ( double * ) CpuNativeHelpers . GetBufferStart ( lhs ) ; var rhsPtr = ( double * ) CpuNativeHelpers . GetBufferStart ( rhs ) ; byte trans = ( byte ) ' ' ; int m = ( int ) rhs . Shape [ 1 ] ; int n = ( int ) lhs . Shape [ 0 ] ; int lda = ( int ) rhs . Strides [ 0 ] ; int ldb = ( int ) lhs . Strides [ 0 ] ; int ldc = ( int ) result . Strides [ 0 ] ; double alpha = 1 ; double beta = 0 ; OpenBlasNative . dgemv_ ( & trans , & m , & n , & alpha , rhsPtr , & lda , lhsPtr , & ldb , & beta , resultPtr , & ldc ) ; } }
Runs the m v double.
Runs the m v double .
// Require lhs to be row-major. This means we must tell BLAS to IntTranspose it (BLAS expects column-major matrices)
lhs must be contiguous in the last dimension
lhs must be contiguous in the last dimension
result
NDArray
None
lhs
NDArray
None
rhs
NDArray
None