optimize_strided_slice.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <vector>
8 #include <memory>
9 
10 #include <transformations_visibility.hpp>
11 
12 #include <ngraph/opsets/opset1.hpp>
13 #include <ngraph/pass/graph_rewrite.hpp>
14 #include <ngraph/slice_plan.hpp>
15 #include <ngraph/util.hpp>
16 
17 namespace ngraph {
18 namespace pass {
19 
20 class TRANSFORMATIONS_API StridedSliceOptimization;
21 class TRANSFORMATIONS_API UselessStridedSliceEraser;
22 class TRANSFORMATIONS_API SharedStridedSliceEraser;
23 class TRANSFORMATIONS_API GroupedStridedSliceOptimizer;
24 
25 } // namespace pass
26 } // namespace ngraph
27 
28 
29 /**
30  * @ingroup ie_transformation_common_api
31  * @brief UselessStridedSliceEraser transformation removes StridedSlice operations
32  * with equal input and output shapes.
33  */
34 class ngraph::pass::UselessStridedSliceEraser: public ngraph::pass::FunctionPass {
35 public:
36  NGRAPH_RTTI_DECLARATION;
37  bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
38 };
39 
40 /**
41  * @ingroup ie_transformation_common_api
42  * @brief SharedStridedSliceEraser transformation replaces group of StridedSlice
43  * operations with first StridedSlice in this group. All SrtideSlices in this group
44  * must be equal and consume the same output port.
45  */
46 class ngraph::pass::SharedStridedSliceEraser: public ngraph::pass::FunctionPass {
47 public:
48  NGRAPH_RTTI_DECLARATION;
49  bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
50 };
51 
52 /**
53  * @ingroup ie_transformation_common_api
54  * @brief GroupedStridedSliceOptimizer transformation replaces group of StridedSlice
55  * operations with VariadicSplit. All StridedSlice operations must slice data
56  * with the same axis and stride = 1.
57  */
58 class ngraph::pass::GroupedStridedSliceOptimizer: public ngraph::pass::FunctionPass {
59 public:
60  NGRAPH_RTTI_DECLARATION;
61  bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
62 };
63 
64 /**
65  * @ingroup ie_transformation_common_api
66  * @brief StridedSliceOptimization transformation executes all transformations
67  * related to StridedSlice optimizations.
68  */
69 class ngraph::pass::StridedSliceOptimization: public ngraph::pass::FunctionPass {
70 public:
71  NGRAPH_RTTI_DECLARATION;
72  bool run_on_function(std::shared_ptr<ngraph::Function> f) override;
73 };
74 
75 ngraph::SlicePlan get_slice_plan(std::shared_ptr<ngraph::opset1::StridedSlice> slice);
GroupedStridedSliceOptimizer transformation replaces group of StridedSlice operations with VariadicSp...
Definition: optimize_strided_slice.hpp:58
SharedStridedSliceEraser transformation replaces group of StridedSlice operations with first StridedS...
Definition: optimize_strided_slice.hpp:46
StridedSliceOptimization transformation executes all transformations related to StridedSlice optimiza...
Definition: optimize_strided_slice.hpp:69
UselessStridedSliceEraser transformation removes StridedSlice operations with equal input and output ...
Definition: optimize_strided_slice.hpp:34
ngraph namespace
Definition: add_fake_quantize_fusion.hpp:14