File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ OPTION(USE_OPENCL "Use OpenCL" OFF)
6666OPTION (ENABLE_DIST "Enable distributed training" OFF )
6767OPTION (DISABLE_WARNINGS "Disable warnings under windows" ON )
6868OPTION (USE_MODULES "Compile dependent libs as submodules together with singa" OFF )
69+ OPTION (USE_DNNL "Use dnnl libs" OFF )
6970OPTION (USE_DIST "Use nccl distributed module" OFF )
7071
7172# TODO: remove all USE_CBLAS in codes
Original file line number Diff line number Diff line change @@ -142,6 +142,13 @@ IF(USE_JAVA)
142142 FIND_PACKAGE (SWIG 3.0 REQUIRED )
143143ENDIF ()
144144
145+ IF (USE_DNNL)
146+ FIND_PATH (DNNL_INCLUDE_DIR NAME "dnnl.hpp" PATHS "${CMAKE_CURRENT_SOURCE_DIR } /dnnl/include" )
147+ FIND_LIBRARY (DNNL_LIBRARIES NAME "dnnl" PATHS "${CMAKE_CURRENT_SOURCE_DIR } /dnnl/lib" )
148+ MESSAGE (STATUS "Found DNNL at ${DNNL_INCLUDE_DIR} " )
149+ INCLUDE_DIRECTORIES (${DNNL_INCLUDE_DIR} )
150+ LIST (APPEND SINGA_LINKER_LIBS ${DNNL_LIBRARIES} )
151+ ENDIF ()
145152
146153IF (USE_DIST)
147154 FIND_PATH (MPI_INCLUDE_DIR NAME "mpi.h" PATHS "/home/ubuntu/mpich-3.3/build/include/" )
Original file line number Diff line number Diff line change 3434#endif
3535#endif // USE_CUDA
3636
37+ #ifdef USE_DNNL
38+ #include < dnnl.hpp>
39+ #endif // USE_DNNL
40+
3741
3842#ifdef USE_OPENCL
3943#include " singa/utils/opencl_utils.h"
@@ -107,6 +111,11 @@ typedef struct _Context {
107111#endif
108112#endif // USE_CUDA
109113
114+ #ifdef USE_DNNL
115+ dnnl::engine *engine;
116+ dnnl::stream *stream;
117+ #endif // USE_DNNL
118+
110119#ifdef USE_OPENCL
111120 // This stores the context ID of the OpenCL context controlled by ViennaCL.
112121 long vcl_ctx_id;
Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -24,11 +24,18 @@ std::shared_ptr<Device> defaultDevice=std::make_shared<CppCPU>();
2424
2525CppCPU::CppCPU () : Device(-1 , 1 ) {
2626 lang_ = kCpp ;
27+ #ifdef USE_DNNL
28+ ctx_.engine = new dnnl::engine (dnnl::engine::kind::cpu, 0 );
29+ ctx_.stream = new dnnl::engine_stream (*ctx_.engine );
30+ #endif // USE_DNNL
2731 // host_ = nullptr;
2832}
2933
3034CppCPU::~CppCPU () {
31-
35+ #ifdef USE_DNNL
36+ delete (ctx_.engine );
37+ delete (ctx_.stream );
38+ #endif // USE_DNNL
3239};
3340
3441void CppCPU::SetRandSeed (unsigned seed) {
You can’t perform that action at this time.
0 commit comments