declmal opened a new issue #6565: URL: https://github.com/apache/incubator-tvm/issues/6565
I am confused about the necessity of the arguments `transa` and `transb` in function `matmul`. See [./python/tvm/contrib/cblas.py](https://github.com/apache/incubator-tvm/blob/master/python/tvm/contrib/cblas.py). This a python interface wrapping external `CBLAS` package for matrix multipliation: *C = matmul(A, B)*. The corresponding c++ interface that wrapping `CBLAS` can be found here: [`./src/runtime/contrib/cblas/gemm_utils.h`](https://github.com/apache/incubator-tvm/blob/master/src/runtime/contrib/cblas/gemm_common.h) In the function ``` inline void CallGemm(TVMArgs args, TVMRetValue* ret, TGemmOp op) ``` Since `A` is `DLTensor*`, I think `transa` can be inferred by A->strides: 1. if A->strides[0] > A->strides[1], `A` is inferred to be row major, thus transa=False. 2. otherwise, `A` is inferred to be column major, thus transa=True. So as to `transb`. PS. In C interface of the `CBLAS`, the matmul interface is given as follows: ``` void cblas_sgemm(const CBLAS_LAYOUT Layout, const CBLAS_TRANSPOSE TransA, const CBLAS_TRANSPOSE TransB, const MKL_INT M, const MKL_INT N, const MKL_INT K, const float alpha, const float *A, const MKL_INT lda, const float *B, const MKL_INT ldb, const float beta, float *C, const MKL_INT ldc) NOTHROW; ``` we need `TransA` and `TransB` here because `A` and `B` here are just pointers instead of `DLTensor*`, there is no clue whether `A` is column-major or row-major. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
