Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the FInplaceIdentity #2572

Merged
merged 2 commits into from
Feb 18, 2019
Merged
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
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