Backends/SiaNet.Backend.TensorSharp/Cpu/MatrixMultiplication.cs
/// <summary>
/// Runs the m v float.
/// </summary>
/// <param name="result">The result.</param>
/// <param name="mat">The mat.</param>
/// <param name="vec">The vec.</param>
/// <exception cref="ArgumentException">lhs must be contiguous in the last dimension</exception>
Runs the m v float.
Runs the m v float .
private static void Run_M_V_float(NDArray result, NDArray mat, NDArray vec)
        {
            if (mat.Strides[1] != 1) throw new ArgumentException("lhs must be contiguous in the last dimension");
            unsafe
            {
                var yPtr = (float*)CpuNativeHelpers.GetBufferStart(result);
                var aPtr = (float*)CpuNativeHelpers.GetBufferStart(mat);
                var xPtr = (float*)CpuNativeHelpers.GetBufferStart(vec);
                byte trans = (byte)'t';
                int m = (int)mat.Shape[1];
                int n = (int)mat.Shape[0];
                int incx = (int)vec.Strides[0];
                int lda = (int)mat.Strides[0];
                int incy = (int)result.Strides[0];
                float alpha = 1;
                float beta = 0;
                OpenBlasNative.sgemv_(&trans, &m, &n, &alpha, aPtr, &lda, xPtr, &incx, &beta, yPtr, &incy);
            }
        }
private static void Run_M_V_float ( NDArray result , NDArray mat , NDArray vec ) { if ( mat . Strides [ 1 ] != 1 ) throw new ArgumentException ( " " ) ; unsafe { var yPtr = ( float * ) CpuNativeHelpers . GetBufferStart ( result ) ; var aPtr = ( float * ) CpuNativeHelpers . GetBufferStart ( mat ) ; var xPtr = ( float * ) CpuNativeHelpers . GetBufferStart ( vec ) ; byte trans = ( byte ) ' ' ; int m = ( int ) mat . Shape [ 1 ] ; int n = ( int ) mat . Shape [ 0 ] ; int incx = ( int ) vec . Strides [ 0 ] ; int lda = ( int ) mat . Strides [ 0 ] ; int incy = ( int ) result . Strides [ 0 ] ; float alpha = 1 ; float beta = 0 ; OpenBlasNative . sgemv_ ( & trans , & m , & n , & alpha , aPtr , & lda , xPtr , & incx , & beta , yPtr , & incy ) ; } }
Runs the m v float.
Runs the m v float .
// 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
mat
NDArray
None
vec
NDArray
None