Skip to content

Commit

Permalink
Fix the FInplaceIdentity (apache#2572)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrendx authored and Wei Chen committed Feb 20, 2019
1 parent 112a27c commit 1853bcc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nnvm/src/pass/plan_memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,14 @@ size_t AllocMemory(const Graph& ret, const IndexedGraph& idx,
bool ignore_all_inputs = (fignore_inputs.count(inode.source->op()) != 0 &&
fignore_inputs[inode.source->op()](
inode.source->attrs).size() == inode.source->num_inputs());
// Identity should only be true if shape.Size() and types match
bool real_identity = identity[ipair] &&
shape_vec[eid_out].Size() == shape_vec[eid_in].Size() &&
dtype_vec[eid_out] == dtype_vec[eid_in];
if (taken[kv.first] == false &&
sid_out == GraphAllocator::kBadStorageID &&
sid_in >= 0 &&
((storage_ref_count[sid_in] == 1 && !ignore_all_inputs) || identity[ipair]) &&
((storage_ref_count[sid_in] == 1 && !ignore_all_inputs) || real_identity) &&
entry_ref_count[eid_out] > 0 &&
shape_vec[eid_out].Size() == shape_vec[eid_in].Size() &&
(dtype_vec[eid_out] == dtype_vec[eid_in] ||
Expand Down

0 comments on commit 1853bcc

Please sign in to comment.