|
23 | 23 | #include "cpu_nop_elimination.hpp"
|
24 | 24 | #include "ngraph/op/convert.hpp"
|
25 | 25 | #include "ngraph/op/pad.hpp"
|
| 26 | +#include "ngraph/op/slice.hpp" |
26 | 27 | #include "ngraph/op/sum.hpp"
|
27 | 28 |
|
28 | 29 | #define TI(x) std::type_index(typeid(x))
|
@@ -64,12 +65,24 @@ HANDLER_DECL(eliminate_convert)
|
64 | 65 | return false;
|
65 | 66 | }
|
66 | 67 |
|
| 68 | +HANDLER_DECL(eliminate_slice) |
| 69 | +{ |
| 70 | + auto slice = std::dynamic_pointer_cast<ngraph::op::Slice>(node); |
| 71 | + if (slice->get_input_shape(0) == slice->get_output_shape(0)) |
| 72 | + { |
| 73 | + function->replace_node(node, node->get_input_op(0)); |
| 74 | + return true; |
| 75 | + } |
| 76 | + return false; |
| 77 | +} |
| 78 | + |
67 | 79 | static const std::unordered_map<std::type_index,
|
68 | 80 | std::function<bool(const std::shared_ptr<ngraph::Function>&,
|
69 | 81 | const std::shared_ptr<ngraph::Node>&)>>
|
70 | 82 | dispatcher{{TI(ngraph::op::Pad), &eliminate_pad},
|
71 | 83 | {TI(ngraph::op::Sum), &eliminate_sum},
|
72 |
| - {TI(ngraph::op::Convert), &eliminate_convert}}; |
| 84 | + {TI(ngraph::op::Convert), &eliminate_convert}, |
| 85 | + {TI(ngraph::op::Slice), &eliminate_slice}}; |
73 | 86 |
|
74 | 87 | bool ngraph::runtime::cpu::pass::CPUNopElimination::run_on_function(
|
75 | 88 | std::shared_ptr<ngraph::Function> function)
|
|
0 commit comments