Repository: incubator-singa Updated Branches: refs/heads/dev dfc422e5b -> 541ad6898
SINGA-218 Implementation for RNN CUDNN version Add checks for cudnn version, which should be >= 5.05 to compile cudnnrnn code Project: http://git-wip-us.apache.org/repos/asf/incubator-singa/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-singa/commit/541ad689 Tree: http://git-wip-us.apache.org/repos/asf/incubator-singa/tree/541ad689 Diff: http://git-wip-us.apache.org/repos/asf/incubator-singa/diff/541ad689 Branch: refs/heads/dev Commit: 541ad689831a8a76654605df5f9770f68f4c92b5 Parents: dfc422e Author: Wei Wang <[email protected]> Authored: Wed Aug 10 12:00:55 2016 +0800 Committer: Wei Wang <[email protected]> Committed: Wed Aug 10 12:44:59 2016 +0800 ---------------------------------------------------------------------- CMakeLists.txt | 2 +- cmake/Templates/singa_config.h.in | 2 ++ src/model/layer/cudnn_rnn.cc | 4 ++-- src/model/layer/cudnn_rnn.h | 4 ++-- src/python/swig/model_layer.i | 10 +++++----- test/singa/test_cudnn_rnn.cc | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/541ad689/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index 38014ce..71acb0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(singa) -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -O2 ") LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Thirdparty) #message(STATUS "module path: ${CMAKE_MODULE_PATH}") http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/541ad689/cmake/Templates/singa_config.h.in ---------------------------------------------------------------------- diff --git a/cmake/Templates/singa_config.h.in b/cmake/Templates/singa_config.h.in index 0220d18..47ae694 100644 --- a/cmake/Templates/singa_config.h.in +++ b/cmake/Templates/singa_config.h.in @@ -14,6 +14,8 @@ #cmakedefine USE_CUDNN #cmakedefine CUDNN_VERSION_MAJOR @CUDNN_VERSION_MAJOR@ +#cmakedefine CUDNN_VERSION_MINOR @CUDNN_VERSION_MINOR@ +#cmakedefine CUDNN_VERSION_PATCH @CUDNN_VERSION_PATCH@ #cmakedefine USE_OPENCL http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/541ad689/src/model/layer/cudnn_rnn.cc ---------------------------------------------------------------------- diff --git a/src/model/layer/cudnn_rnn.cc b/src/model/layer/cudnn_rnn.cc index 896c1e9..bfbfa48 100644 --- a/src/model/layer/cudnn_rnn.cc +++ b/src/model/layer/cudnn_rnn.cc @@ -17,7 +17,7 @@ */ #include "./cudnn_rnn.h" #ifdef USE_CUDNN -#if CUDNN_VERSION_MAJOR >= 5 +#if CUDNN_VERSION_MAJOR >= 5 && CUDNN_VERSION_PATCH >= 5 #include <cudnn.h> #include <chrono> #include "./cudnn_utils.h" @@ -428,5 +428,5 @@ const std::pair<vector<Tensor>, vector<Tensor>> CudnnRNN::Backward( } } // namespace singa -#endif // CUDNN_VERSION_MAJOR >= 5 +#endif // CUDNN_VERSION_MAJOR >= 5 && CUDNN_VERSION_PATCH >= 5 #endif // USE_CUDNN http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/541ad689/src/model/layer/cudnn_rnn.h ---------------------------------------------------------------------- diff --git a/src/model/layer/cudnn_rnn.h b/src/model/layer/cudnn_rnn.h index d2f8db5..cfb8aac 100644 --- a/src/model/layer/cudnn_rnn.h +++ b/src/model/layer/cudnn_rnn.h @@ -20,7 +20,7 @@ #define SRC_MODEL_LAYER_CUDNN_RNN_H_ #include "singa/singa_config.h" #ifdef USE_CUDNN -#if CUDNN_VERSION_MAJOR >= 5 +#if CUDNN_VERSION_MAJOR >= 5 && CUDNN_VERSION_PATCH >= 5 #include <string> #include <utility> #include <vector> @@ -82,6 +82,6 @@ class CudnnRNN : public RNN { } // namespace singa -#endif // CUDNN_VERSION_MAJOR >= 5 +#endif // CUDNN_VERSION_MAJOR >= 5 && CUDNN_VERSION_PATCH >= 5 #endif // USE_CUDNN #endif // SRC_MODEL_LAYER_CUDNN_RNN_H_ http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/541ad689/src/python/swig/model_layer.i ---------------------------------------------------------------------- diff --git a/src/python/swig/model_layer.i b/src/python/swig/model_layer.i index 9d39301..6cbfe8f 100644 --- a/src/python/swig/model_layer.i +++ b/src/python/swig/model_layer.i @@ -34,6 +34,7 @@ #include "../src/model/layer/cudnn_rnn.h" #include "singa/core/tensor.h" #include "singa/proto/model.pb.h" +#include "singa/singa_config.h" using singa::Tensor; using singa::ParamSpec; using singa::DataType; @@ -78,12 +79,9 @@ class Layer { std::shared_ptr<Layer> CreateLayer(const std::string& type); const std::vector<std::string> GetRegisteredLayers(); class RNN : public Layer { - /* - public: - void Setup(const std::vector<size_t>& in_sample_shape, - const std::string& proto_str) override; - */ }; + +#if CUDNN_VERSION_MINOR >= 5 && CUDNN_VERSION_PATCH >= 5 class CudnnRNN : public RNN { public: // note: Must use std::vector instead of vector. @@ -95,5 +93,7 @@ class CudnnRNN : public RNN { const std::vector<size_t> GetOutputSampleShape() const override; }; +#endif // CUDNN_VERSION_MINOR >= 5 && CUDNN_VERSION_PATCH >= 5 + } http://git-wip-us.apache.org/repos/asf/incubator-singa/blob/541ad689/test/singa/test_cudnn_rnn.cc ---------------------------------------------------------------------- diff --git a/test/singa/test_cudnn_rnn.cc b/test/singa/test_cudnn_rnn.cc index e0de02e..effb3b1 100644 --- a/test/singa/test_cudnn_rnn.cc +++ b/test/singa/test_cudnn_rnn.cc @@ -21,7 +21,7 @@ #include "../src/model/layer/cudnn_rnn.h" #ifdef USE_CUDNN -#if CUDNN_VERSION_MAJOR >= 5 +#if CUDNN_VERSION_MAJOR >= 5 && CUDNN_VERSION_PATCH >= 5 #include "gtest/gtest.h" @@ -177,5 +177,5 @@ TEST_F(TestCudnnRNN, Backward) { std::copy(tmp.begin(), tmp.end(), dhyptr.begin()); } } -#endif // CUDNN_VERSION_MAJOR >= 5 +#endif // CUDNN_VERSION_MAJOR >= 5 && CUDNN_VERSION_PATCH >= 5 #endif // USE_CUDNN
