You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/06/20 21:50:22 UTC

[GitHub] zheng-da closed pull request #11005: Handle MKLDNN fallback correct in custom operator

zheng-da closed pull request #11005: Handle MKLDNN fallback correct in custom operator
URL: https://github.com/apache/incubator-mxnet/pull/11005
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/src/operator/custom/custom.cc b/src/operator/custom/custom.cc
index d117a284216..ef55469aea9 100644
--- a/src/operator/custom/custom.cc
+++ b/src/operator/custom/custom.cc
@@ -29,6 +29,7 @@
 
 #include "../elemwise_op_common.h"
 #include "../operator_common.h"
+#include "../nn/mkldnn/mkldnn_base-inl.h"
 
 namespace mxnet {
 namespace op {
@@ -56,7 +57,19 @@ inline void AllocateNDArrayCopy(NDArray** nd,
   switch (stype) {
     case kUndefinedStorage:
     case kDefaultStorage:
+#if MXNET_USE_MKLDNN == 1
+      if (inputs[idx].IsMKLDNNData()) {
+        *nd = new NDArray(inputs[idx].shape(), inputs[idx].ctx(), false,
+                          inputs[idx].dtype());
+        const mkldnn::memory *mem = inputs[idx].GetMKLDNNData();
+        (*nd)->CopyFrom(*mem);
+        MKLDNNStream::Get()->Submit();
+      } else {
+        *nd = new NDArray(inputs[idx].data(), dev_id);
+      }
+#else
       *nd = new NDArray(inputs[idx].data(), dev_id);
+#endif
       break;
     case kRowSparseStorage:
       aux.push_back(inputs[idx].aux_data(rowsparse::kIdx));


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services