Skip to content

Commit

Permalink
CBLAS_OFFSET only available for MKL
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Jul 23, 2020
1 parent 82bcf0c commit 5a4f0c9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions python/tvm/relay/grammar/py3/RelayLexer.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions python/tvm/relay/grammar/py3/RelayParser.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion python/tvm/relay/grammar/py3/RelayVisitor.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/runtime/contrib/cblas/cblas.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ using namespace runtime;

inline CBLAS_TRANSPOSE BooleanToTranspose(bool trans) { return trans ? CblasTrans : CblasNoTrans; }

#if USE_MKL_BLAS == 1
inline CBLAS_OFFSET StringToOffset(const std::string offset_type) {
if (offset_type != "CblasFixOffset" && offset_type != "CblasColOffset" &&
offset_type != "CblasRowOffset") {
Expand All @@ -56,16 +57,21 @@ inline CBLAS_OFFSET StringToOffset(const std::string offset_type) {
}
return CblasRowOffset;
}
#endif

inline char BooleanToTransposeChar(bool trans) { return trans ? 'T' : 'N'; }

struct CblasGemmU8S8S32Op {
void operator()(bool ta, bool tb, int M, int N, int K, float alpha, const void* A, int lda,
int offset_a, const void* B, int ldb, int offset_b, float beta, int* C, int ldc,
const std::string offset_ctype, int* offset_c) {
#if USE_MKL_BLAS == 1
cblas_gemm_s8u8s32(CblasColMajor, BooleanToTranspose(ta), BooleanToTranspose(tb),
StringToOffset(offset_ctype), M, N, K, alpha, A, lda, offset_a, B, ldb,
offset_b, beta, C, ldc, offset_c);
#else
LOG(FATAL) << "Quantized Gemm is supported with MKL Blas only";
#endif
}
};

Expand Down
2 changes: 1 addition & 1 deletion tests/python/contrib/test_cblas.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def verify(target="llvm"):
if not tvm.runtime.enabled(target):
print("skip because %s is not enabled..." % target)
return
if not tvm.get_global_func("tvm.contrib.cblas.matmul", True):
if not tvm.get_global_func("tvm.contrib.cblas.matmul_u8s8s32", True):
print("skip because extern function is not available")
return
ctx = tvm.cpu(0)
Expand Down

0 comments on commit 5a4f0c9

Please sign in to comment.