Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
72821b20
Commit
72821b20
authored
Nov 14, 2019
by
Haichen Shen
Committed by
Tianqi Chen
Nov 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Contrib] Add MKL DNN option (#4323)
* [Contrib] Add MKL DNN * update * update
parent
2573b3b8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
1 deletions
+22
-1
CMakeLists.txt
+1
-0
cmake/config.cmake
+3
-0
cmake/modules/contrib/BLAS.cmake
+7
-0
src/runtime/contrib/cblas/cblas.cc
+10
-0
topi/python/topi/x86/dense.py
+1
-1
No files found.
CMakeLists.txt
View file @
72821b20
...
...
@@ -53,6 +53,7 @@ tvm_option(PICOJSON_PATH "Path to PicoJSON" "3rdparty/picojson")
# Contrib library options
tvm_option
(
USE_BLAS
"The blas library to be linked"
none
)
tvm_option
(
USE_MKL_PATH
"MKL root path when use MKL blas"
none
)
tvm_option
(
USE_MKLDNN
"Build with MKLDNN"
OFF
)
tvm_option
(
USE_CUDNN
"Build with cuDNN"
OFF
)
tvm_option
(
USE_CUBLAS
"Build with cuBLAS"
OFF
)
tvm_option
(
USE_MIOPEN
"Build with ROCM:MIOpen"
OFF
)
...
...
cmake/config.cmake
View file @
72821b20
...
...
@@ -115,6 +115,9 @@ set(USE_BLAS none)
# set(USE_MKL_PATH <path to venv or site-packages directory>) if using `pip install mkl`
set
(
USE_MKL_PATH none
)
# Whether use MKLDNN library
set
(
USE_MKLDNN OFF
)
# Whether use OpenMP thread pool, choices: gnu, intel
# Note: "gnu" uses gomp library, "intel" uses iomp5 library
set
(
USE_OPENMP none
)
...
...
cmake/modules/contrib/BLAS.cmake
View file @
72821b20
...
...
@@ -55,3 +55,10 @@ elseif(USE_BLAS STREQUAL "none")
else
()
message
(
FATAL_ERROR
"Invalid option: USE_BLAS="
${
USE_BLAS
}
)
endif
()
if
(
USE_MKLDNN STREQUAL
"ON"
)
find_library
(
BLAS_LIBRARY_MKLDNN dnnl
)
list
(
APPEND TVM_RUNTIME_LINKER_LIBS
${
BLAS_LIBRARY_MKLDNN
}
)
add_definitions
(
-DUSE_DNNL=1
)
message
(
STATUS
"Use MKLDNN library "
${
BLAS_LIBRARY_MKLDNN
}
)
endif
()
src/runtime/contrib/cblas/cblas.cc
View file @
72821b20
...
...
@@ -31,6 +31,9 @@ extern "C" {
#else
#include <cblas.h>
#endif
#if USE_DNNL == 1
#include <dnnl.h>
#endif
}
namespace
tvm
{
...
...
@@ -40,12 +43,19 @@ using namespace runtime;
inline
CBLAS_TRANSPOSE
BooleanToTranspose
(
bool
trans
)
{
return
trans
?
CblasTrans
:
CblasNoTrans
;
}
inline
char
BooleanToTransposeChar
(
bool
trans
)
{
return
trans
?
'T'
:
'N'
;
}
struct
CblasSgemmOp
{
typedef
float
TDatatype
;
void
operator
()(
bool
ta
,
bool
tb
,
int
M
,
int
N
,
int
K
,
float
alpha
,
float
*
A
,
int
lda
,
float
*
B
,
int
ldb
,
float
beta
,
float
*
C
,
int
ldc
)
{
#if USE_DNNL == 1
dnnl_sgemm
(
BooleanToTransposeChar
(
tb
),
BooleanToTransposeChar
(
ta
),
N
,
M
,
K
,
alpha
,
B
,
ldb
,
A
,
lda
,
beta
,
C
,
ldc
);
#else
cblas_sgemm
(
CblasColMajor
,
BooleanToTranspose
(
ta
),
BooleanToTranspose
(
tb
),
M
,
N
,
K
,
alpha
,
A
,
lda
,
B
,
ldb
,
beta
,
C
,
ldc
);
#endif
}
};
...
...
topi/python/topi/x86/dense.py
View file @
72821b20
...
...
@@ -32,7 +32,7 @@ def _declaration_dense(cfg, data, weight, bias=None, out_dtype=None):
if
"cblas"
in
target
.
libs
:
C
=
cblas
.
matmul
(
data
,
weight
,
False
,
True
)
if
bias
is
not
None
:
C
=
tvm
.
compute
(
C
.
shape
,
lambda
i
,
j
:
C
[
i
,
j
]
+
bias
[
j
]
.
astype
(
out_dtype
)
,
C
=
tvm
.
compute
(
C
.
shape
,
lambda
i
,
j
:
C
[
i
,
j
]
+
bias
[
j
],
tag
=
tag
.
BROADCAST
)
return
C
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment