zheng-da commented on a change in pull request #8302: Refactor operators & MKLDNN URL: https://github.com/apache/incubator-mxnet/pull/8302#discussion_r161936090
########## File path: include/mxnet/ndarray.h ########## @@ -534,15 +491,12 @@ class NDArray { CHECK_GE(ptr_->shandle.size, shape.Size() * mshadow::mshadow_sizeof(dtype)) << "NDArray.AsArray: target memory size is bigger"; -#if MKL_EXPERIMENTAL == 1 - if (Mkl_mem_ != nullptr) { - // convert prv to cpu - Mkl_mem_->check_and_prv_to_cpu(ptr_->shandle.dptr); - } -#endif + // We can't reuse memory in a view. + CHECK(!IsView()); NDArray ret = *this; ret.shape_ = shape; ret.dtype_ = dtype; + ret.reuse_ = true; Review comment: I searched for it in the entire repo, including submodules, and only find three locations it's used: ``` src/executor/graph_executor.cc: data_entry_[i] = src.AsArray(vshape[i], vdtype[i]); src/imperative/imperative_utils.h: *arrays[i] = buff.AsArray(shapes[i], dtypes[i]); src/imperative/imperative_utils.h: *arrays[i] = arrays[mem_plan[i].sid]->AsArray(shapes[i], dtypes[i]); ``` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services