Commit 7ac647ac authored by Nick Korovaiko's avatar Nick Korovaiko Committed by Scott Cyphers

non destructive ml opt (#1454)

parent e84ca5a6
......@@ -49,9 +49,14 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
{
auto output = &node->get_outputs().at(oi_pair.output).get_tensor();
auto input = &node->get_inputs().at(oi_pair.input).get_tensor();
auto input_node = node->get_inputs().at(oi_pair.input).get_output().get_node();
if (node->liveness_free_list.count(input) != 0 &&
node->liveness_new_list.count(output) != 0)
//an input tensor can be reused if this is the last use or
//an op isn't destructive (i.e. Reshape(DimShuffle))
if ((node->liveness_free_list.count(input) != 0 &&
node->liveness_new_list.count(output) != 0) ||
(!oi_pair.destructive && !input_node->is_parameter() &&
!input_node->is_constant()))
{
in_place_outputs.insert({output, input});
reused_inputs.insert(input);
......
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