Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[numpy] Fix concat and slice operator #14549

Merged
merged 1 commit into from
Mar 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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