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 2019/09/24 07:56:16 UTC

[GitHub] [incubator-mxnet] ZhennanQin commented on a change in pull request #16258: [mkldnn-v1.0] Add MKL-DNN reshape&flatten&expand_dims

ZhennanQin commented on a change in pull request #16258: [mkldnn-v1.0] Add MKL-DNN reshape&flatten&expand_dims
URL: https://github.com/apache/incubator-mxnet/pull/16258#discussion_r327475190
 
 

 ##########
 File path: src/operator/nn/mkldnn/mkldnn_reshape.cc
 ##########
 @@ -89,42 +88,31 @@ MKLDNNReshapeFwd::MKLDNNReshapeFwd(const OpReqType &req,
 }
 
 int MKLDNNReshapeFwd::GetWorkspaceSize() {
-  return temp_ ? temp_->get_primitive_desc().get_size() : 0;
-}
-
-void MKLDNNReshapeFwd::SetNewMem(const NDArray &input,
-                                 const NDArray &output,
-                                 void* workspace) {
-  if (input.IsMKLDNNData()) {
-    this->data_->set_data_handle(input.GetMKLDNNData()->get_data_handle());
-  } else {
-    MSHADOW_TYPE_SWITCH(input.dtype(), DTYPE, {
-      this->data_->set_data_handle(input.data().dptr<DTYPE>());
-    })
-  }
-
-  if (output.IsMKLDNNData()) {
-    this->out_->set_data_handle(output.GetMKLDNNData()->get_data_handle());
-  } else {
-    MSHADOW_TYPE_SWITCH(output.dtype(), DTYPE, {
-      this->out_->set_data_handle(output.data().dptr<DTYPE>());
-    })
-  }
-
-  if (workspace) {
-    this->temp_->set_data_handle(workspace);
-  }
+  return temp_ ? temp_->get_desc().get_size() : 0;
 }
 
 void MKLDNNReshapeFwd::Execute(const NDArray &input,
                                const NDArray &output,
                                void* workspace) {
-  // set memory handles
-  SetNewMem(input, output, workspace);
-  // register primitives
   auto stream = MKLDNNStream::Get();
-  for (auto &v : this->prims_) {
-    stream->RegisterPrim(v);
+  auto in_mem = input.GetMKLDNNData();
+  auto in_md = in_mem->get_desc();
+  // register primitives and arguments
+  size_t prims_size = prims_.size();
+  if (prims_size == 1) {
+    args_map_.push_back({{MKLDNN_ARG_FROM, *in_mem},
 
 Review comment:
   Strange code. always push_back, but not clear? What will happen in 2nd execution?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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