TaoLv commented on a change in pull request #10315: [MXNET-249] Add inplace 
support to mkldnn sum
URL: https://github.com/apache/incubator-mxnet/pull/10315#discussion_r178475399
 
 

 ##########
 File path: src/operator/nn/mkldnn/mkldnn_sum.cc
 ##########
 @@ -49,23 +49,42 @@ void Sum(const mkldnn::memory &arr1, const mkldnn::memory 
&arr2,
 void MKLDNNSumForward(const nnvm::NodeAttrs& attrs, const OpContext &ctx,
                       const std::vector<NDArray> &inputs, const OpReqType &req,
                       const NDArray &out_data) {
+  if (req == kNullOp) {
+    return;
+  }
+
   TmpMemMgr::Get()->Init(ctx.requested[0]);
   std::vector<mkldnn::primitive::at> in_prims;
   std::vector<mkldnn::memory::primitive_desc> in_pds(inputs.size());
   std::vector<float> scales(inputs.size(), 1);
   in_prims.reserve(inputs.size());
+  bool pd_same = true;
   for (size_t i = 0; i < inputs.size(); i++) {
     auto in_mem = inputs[i].GetMKLDNNData();
     in_prims.push_back(*in_mem);
     in_pds[i] = in_mem->get_primitive_desc();
+    // pd_same = pd_same && (in_pds[i] == in_pds[0]);
 
 Review comment:
   Finally I realize that, for inplace computation, mkldnn sum doesn't need all 
inputs should have the same layout, but need output should have same layout and 
same memory address with those of inputs[0]. So I removed the input layouts 
check here. I have changed the description in this PR. Do you think I need 
document it somewhere?

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