Unverified Commit 80923525 authored by Adam Procter's avatar Adam Procter Committed by GitHub

Merge branch 'master' into krovatkin/rs_concat

parents e8735112 ad30e973
......@@ -68,9 +68,13 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
// Non-destructive kernels can pass through if memory sharing is disabled
if ((node->liveness_free_list.count(input) != 0 ||
std::dynamic_pointer_cast<op::GetOutputElement>(node) ||
(m_disable_memory_sharing && !oi_pair.destructive)) &&
(m_disable_memory_sharing && !oi_pair.destructive &&
!input_node->is_parameter() && !input_node->is_constant())) &&
node->liveness_new_list.count(output) != 0)
{
NGRAPH_DEBUG << "Reusing " << input->get_name() << " for "
<< output->get_name();
in_place_outputs.insert({output, input});
reused_inputs.insert(input);
}
......
......@@ -523,7 +523,21 @@ bool ngraph::pass::ReshapeSinking::run_on_function(std::shared_ptr<ngraph::Funct
}
else if (auto slice = std::dynamic_pointer_cast<op::Slice>(n))
{
sink_slice(slice, reorders, reshapes_to_delete);
// A heuristic. If Reshape has multiple slice users, if sunk
// it will be replicated by the number of its users
// TODO: we should have a pre-pass that looks at this kind of
// scenarios and marks some reshapes as too "toxic" to sink
// For now, this heuristic works really well.
// Note, get_users(*true*) which means we only care about
// live users of Reshape
if (slice->get_argument(0)->get_users(true).size() == 1)
{
sink_slice(slice, reorders, reshapes_to_delete);
}
else
{
materialize_shapes(n, reorders, reshapes_to_delete);
}
}
else if (auto pad = std::dynamic_pointer_cast<op::Pad>(n))
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment