You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by re...@apache.org on 2019/03/29 02:51:02 UTC
[incubator-mxnet] branch numpy updated: fix concat and slice
(#14549)
This is an automated email from the ASF dual-hosted git repository.
reminisce pushed a commit to branch numpy
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/numpy by this push:
new 12018d2 fix concat and slice (#14549)
12018d2 is described below
commit 12018d2a4c568deec93e9c770a767733d26e61e6
Author: Tao Lv <ta...@intel.com>
AuthorDate: Fri Mar 29 10:50:41 2019 +0800
fix concat and slice (#14549)
---
src/operator/nn/mkldnn/mkldnn_concat.cc | 12 ++++++------
src/operator/nn/mkldnn/mkldnn_slice.cc | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/operator/nn/mkldnn/mkldnn_concat.cc b/src/operator/nn/mkldnn/mkldnn_concat.cc
index 8e2b577..7b266ef 100644
--- a/src/operator/nn/mkldnn/mkldnn_concat.cc
+++ b/src/operator/nn/mkldnn/mkldnn_concat.cc
@@ -92,13 +92,13 @@ void MKLDNNConcatBackward(const nnvm::NodeAttrs& attrs, const OpContext &ctx,
auto gz_mem = inputs[0].GetMKLDNNData();
mkldnn::memory::primitive_desc gz_pd = gz_mem->get_primitive_desc();
/* init the offset */
- mkldnn::memory::dims offsets = {0, 0, 0, 0};
+ mkldnn::memory::dims offsets(outputs[0].shape().ndim());
+ for (auto &v : offsets) {
+ v = 0;
+ }
+
for (int i = 0; i < num_in_data; i++) {
- mkldnn::memory::dims diff_src_tz
- = {static_cast<int>(outputs[i].shape()[0]),
- static_cast<int>(outputs[i].shape()[1]),
- static_cast<int>(outputs[i].shape()[2]),
- static_cast<int>(outputs[i].shape()[3])};
+ mkldnn::memory::dims diff_src_tz(outputs[i].shape().begin(), outputs[i].shape().end());
auto diff_src_mpd = outputs[i].GetMKLDNNData()->get_primitive_desc();
auto gradi_mem_ = CreateMKLDNNMem(outputs[i], diff_src_mpd, req[i]);
// create view from gy to gxs[i]
diff --git a/src/operator/nn/mkldnn/mkldnn_slice.cc b/src/operator/nn/mkldnn/mkldnn_slice.cc
index 3f3d820..96a8afd 100644
--- a/src/operator/nn/mkldnn/mkldnn_slice.cc
+++ b/src/operator/nn/mkldnn/mkldnn_slice.cc
@@ -42,7 +42,7 @@ MKLDNNSliceFwd::MKLDNNSliceFwd(const SliceParam ¶m,
mkldnn::memory::dims offsets(N);
for (uint32_t i = 0; i < N; ++i) {
int s = 0;
- if (param.begin[i]) {
+ if (i < param.begin.ndim() && param.begin[i]) {
s = *param.begin[i];
if (s < 0) s += ishape[i];
}