Commit bcd1f46f authored by Robert Kimball's avatar Robert Kimball Committed by Scott Cyphers

Add ReplaceSlice to ZeroDimTensorEliminiation pass (#3899)

* Add ReplaceSlice to ZeroDimTensorEliminiation pass

* style
parent 66ce838c
......@@ -27,7 +27,9 @@
#include "ngraph/op/max_pool.hpp"
#include "ngraph/op/pad.hpp"
#include "ngraph/op/product.hpp"
#include "ngraph/op/replace_slice.hpp"
#include "ngraph/op/sum.hpp"
#include "ngraph/type.hpp"
#include "zero_dim_tensor_elimination.hpp"
using namespace std;
......@@ -131,6 +133,20 @@ bool pass::ZeroDimTensorElimination::run_on_function(shared_ptr<Function> f)
continue;
}
}
else if (auto replace_slice = as_type_ptr<op::ReplaceSlice>(n))
{
const Shape& replacement_shape = replace_slice->input(1).get_shape();
if (shape_size(replacement_shape) == 0)
{
// Op is a noop
Output<Node> source_output = replace_slice->input(0).get_source_output();
Output<Node> output = replace_slice->output(0);
for (Input<Node> input : output.get_target_inputs())
{
input.replace_source_output(source_output);
}
}
}
auto source_output = n->input(0).get_source_output();
......
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