I found in wiki link, that by definition, a row-major tensor should have decreased strides.
So, A or B here can either be row-major or column-major, that’s why we need IsInPlaceTransposed . (Although in tvm, tensors are most commonly stored in row-major.)
Finally I understand that my confusion actually comes from the necessity of the arguments transa and transb in ./python/tvm/contrib/cblas.py.
Since A is DLTensor*, I think transa can be determined by A->strides:
-
if A->strides[0] > A->strides[1],
Ais inferred to be row major, transa=False. -
otherwise,
Ais inferred to be column major, 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.