Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Add ReplaceSlice to ZeroDimTensorEliminiation pass (#3899)
Browse files Browse the repository at this point in the history
* Add ReplaceSlice to ZeroDimTensorEliminiation pass

* style
  • Loading branch information
rkimballn1 authored and diyessi committed Nov 15, 2019
1 parent 66ce838 commit bcd1f46
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ngraph/pass/zero_dim_tensor_elimination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit bcd1f46

Please sign in to comment.