TaoLv commented on a change in pull request #12746: Add env flag to disable 
MKLDNN cache (MXNET_MKLDNN_CACHE_ENABLED)
URL: https://github.com/apache/incubator-mxnet/pull/12746#discussion_r225756026
 
 

 ##########
 File path: src/operator/nn/mkldnn/mkldnn_base-inl.h
 ##########
 @@ -147,6 +148,61 @@ static inline bool MKLDNNEnvSet() {
   return is_mkldnn_enabled;
 }
 
+static inline int GetMKLDNNCacheSize() {
+  static int mkldnn_cache_size = dmlc::GetEnv("MXNET_MKLDNN_CACHE_SIZE", -1);
+  return mkldnn_cache_size;
+}
+
+// TODO(alex): (MXNET-1075) Will remove env variable and calculate cache size 
during runtime
+//template<typename S, typename I, typename H>
+//static typename std::unordered_map<S, I, H>::iterator AddToCache(
+//    const std::unordered_map<S, I, H> &cache, const S &key, const I &item) {
+//  int mkldnn_cache_size = GetMKLDNNCacheSize();
+//  if (mkldnn_cache_size != -1 && static_cast<int>(cache.size()) > 
mkldnn_cache_size)
+//    cache.erase(cache.begin());
+//  auto ins_return = cache.insert(std::pair<S, I>(key, item));
+//  CHECK(ins_return.second);
+//  return ins_return.first;
+//}
+
+template<typename K, typename V, typename H>
+class MKLDNNCache {
 
 Review comment:
   Hi Alex, would you mind measuring the performance change of a deep model 
like ResNet-152 after `MKLDNNCache` is added? Thanks.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to