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

Commit

Permalink
create fallback arrays in place
Browse files Browse the repository at this point in the history
  • Loading branch information
azai91 committed Aug 28, 2018
1 parent 78dcfb1 commit d875592
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/executor/attach_op_execs_pass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class StatefulComputeExExecutor : public OpExecutor {
op_ctx.run_ctx = rctx;
#if MXNET_USE_MKLDNN == 1
InvalidateOutputs(out_array, req);
in_array_fallback = CreateDefaultInputs(in_array);
CreateDefaultInputs(in_array, in_array_fallback);
fcompute_(state_, op_ctx, in_array_fallback, req, out_array);
return;
#endif
Expand Down Expand Up @@ -232,7 +232,7 @@ class FComputeExExecutor : public OpExecutor {
// TODO(alex): (MXNET-847) Remove this fallback feature after subgraph implemented
const auto is_mkldnn = Op::GetAttr<bool>("TIsMKLDNN");
if (!is_mkldnn.get(attrs_.op, false)) {
in_array_fallback = CreateDefaultInputs(in_array);
CreateDefaultInputs(in_array, in_array_fallback);
fcompute_(attrs_, op_ctx, in_array_fallback, req, out_array);
return;
}
Expand Down
9 changes: 4 additions & 5 deletions src/operator/nn/mkldnn/mkldnn_base-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,15 +357,14 @@ static inline void InvalidateOutputs(const std::vector<NDArray> &arrs,
}

// TODO(alexzai): (MXNET-856) Remove helper function after subgraph feature added
static inline std::vector<NDArray> CreateDefaultInputs(const std::vector<NDArray> &arrs) {
std::vector<NDArray> buffer(arrs.size());
static inline void CreateDefaultInputs(const std::vector<NDArray> &arrs,
const std::vector<NDArray> &out_arrs) {
for (size_t i = 0; i < arrs.size(); ++i) {
if (arrs[i].IsMKLDNNData())
buffer[i] = arrs[i].Reorder2Default();
out_arrs[i] = arrs[i].Reorder2Default();
else
buffer[i] = arrs[i];
out_arrs[i] = arrs[i];
}
return buffer;
}

const mkldnn::memory *GetWeights(const NDArray &arr,
Expand Down

0 comments on commit d875592

Please sign in to comment.