示例#1
0
        public unsafe void CouldCallHiLevelSgemm()
        {
            var mnk = 2;
            var x   = new float[mnk * mnk];

            for (int i = 0; i < mnk * mnk; i++)
            {
                x[i] = (i + 1);
            }

            var h  = x.AsMemory().Pin();
            var c  = new float[mnk * mnk];
            var hc = c.AsMemory().Pin();

            CBLAS.Sgemm(LAYOUT.RowMajor, TRANSPOSE.NoTrans, TRANSPOSE.NoTrans,
                        mnk, mnk, mnk, alpha: 1f, (float *)h.Pointer, mnk, (float *)h.Pointer, mnk, beta: 0, (float *)hc.Pointer, mnk);
        }
示例#2
0
        public static unsafe void Sample()
        {
            BlasNumThreads = 1;

            var mnk = 2;
            var x   = new float[mnk * mnk];
            var c   = new float[mnk * mnk];

            for (int i = 0; i < mnk * mnk; i++)
            {
                x[i] = (i + 1);
            }

            fixed(float *xP = &x[0])
            fixed(float *cP = &c[0])
            {
                CBLAS.Sgemm(LAYOUT.RowMajor, TRANSPOSE.NoTrans, TRANSPOSE.NoTrans,
                            mnk, mnk, mnk, alpha: 1f, xP, mnk, xP, mnk, beta: 0, cP, mnk);
            }
        }