Skip to content

Commit

Permalink
fix concat and slice (apache#14549)
Browse files Browse the repository at this point in the history
  • Loading branch information
TaoLv authored and reminisce committed Apr 12, 2019
1 parent b20ed37 commit dad43a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/operator/nn/mkldnn/mkldnn_concat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/operator/nn/mkldnn/mkldnn_slice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ MKLDNNSliceFwd::MKLDNNSliceFwd(const SliceParam &param,
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];
}
Expand Down

0 comments on commit dad43a4

Please sign in to comment.