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/19 03:01:56 UTC

[GitHub] pengzhao-intel closed pull request #11095: [MKLDNN] reorder the mem format for the AddBack mode in case src & dst is different

pengzhao-intel closed pull request #11095: [MKLDNN] reorder the mem format for the AddBack mode in case src & dst is different
URL: https://github.com/apache/incubator-mxnet/pull/11095
 
 
   

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/nn/mkldnn/mkldnn_base.cc b/src/operator/nn/mkldnn/mkldnn_base.cc
index 1bd1581dbc2..4622c0cee05 100644
--- a/src/operator/nn/mkldnn/mkldnn_base.cc
+++ b/src/operator/nn/mkldnn/mkldnn_base.cc
@@ -128,8 +128,14 @@ void CommitOutput(const NDArray &arr, const mkldnn_output_t &res) {
   if (res.first == CopyBack) {
     const_cast<NDArray &>(arr).CopyFrom(*res.second);
   } else if (res.first == AddBack) {
-    auto mem = arr.GetMKLDNNData(res.second->get_primitive_desc());
-    CHECK(mem != nullptr);
+    const mkldnn::memory *mem = arr.GetMKLDNNData();
+    auto arr_desc = mem->get_primitive_desc();
+    auto res_desc = res.second->get_primitive_desc();
+    if (arr_desc == res_desc) {
+        mem = arr.GetMKLDNNData(res_desc);
+    } else {
+        mem = arr.GetMKLDNNDataReorder(res_desc);
+    }
     // We have to allocate new memory for the sum result.
     auto sum_res = TmpMemMgr::Get()->Alloc(
         res.second->get_primitive_desc());


 

----------------------------------------------------------------
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