Coder Social home page Coder Social logo

Comments (11)

wangshankun avatar wangshankun commented on May 18, 2024 1

openblas considered the cache control&reuse,share job,multithreading , that three factors speed up the gemm

from paddle-lite.

cocodark avatar cocodark commented on May 18, 2024

Is the 'loss' you mentioned the accurancy loss cased by quantification?

from paddle-lite.

victorygogogo avatar victorygogogo commented on May 18, 2024

I mean if the input matrix need transpose ,I use this function cause a wrong result ,may cause the loss is bigger. do you knonw the function on "caffe caffe_cpu_gemm"
void caffe_cpu_gemm(const CBLAS_TRANSPOSE TransA,
const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
const float alpha, const float* A, const float* B, const float beta,
float* C) {
LOG(INFO) << "Running for caffe_cpu_gemm trans start" ;
int lda = (TransA == CblasNoTrans) ? K : M;
int ldb = (TransB == CblasNoTrans) ? N : K;
cblas_sgemm(CblasRowMajor, TransA, TransB, M, N, K, alpha, A, lda, B,
ldb, beta, C, N);
}

from paddle-lite.

cocodark avatar cocodark commented on May 18, 2024

Our Gemmer is not support transposing matrix indeed, we put transpose procedure in the conversion of model, in order to accelerate matrix manipulation. @victorygogogo

from paddle-lite.

cocodark avatar cocodark commented on May 18, 2024

`/**

  • transpose matrix in advance

  • @param data

  • @param shape

  • @return
    */
    float *trans_matrix(const float *data, vector shape) {

    int m = shape[0];
    int n = shape[1];

    float *trans = new float[m * n];

    for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {

         trans[i * m + j] = data[j * n + i];
     }
    

    }
    return trans;

}` in caffe2mdl.cpp @victorygogogo

from paddle-lite.

victorygogogo avatar victorygogogo commented on May 18, 2024

OK ,thank you

from paddle-lite.

cocodark avatar cocodark commented on May 18, 2024

You're welcome.

from paddle-lite.

victorygogogo avatar victorygogogo commented on May 18, 2024

I found that ,I use this function ,it is slower than the openblas lib of gemm.by the way ,I use neon on a phone.

from paddle-lite.

cocodark avatar cocodark commented on May 18, 2024

You found our gemm is slower than openblas?

from paddle-lite.

victorygogogo avatar victorygogogo commented on May 18, 2024

@cocodark yes , I use neon ,but some matrix needs transpose,so I did transpose in this function to match the "cblas_sgemm" function. even if not use transpose ,I test 30 times cost time is about6.7s, if use the cblas_sgemm,it costs about 2.7s.

from paddle-lite.

cocodark avatar cocodark commented on May 18, 2024

@victorygogogo ,excellent research work, currently our gemm is accelerated by neon, we'll try the tricks mentioned by @wangshankun ,such as cache control&reuse 、 multithreading to make it faster.If you are interested in gemm optimization work, code contributions will be appreciated.

from paddle-lite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.