softmax_fusion.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <transformations_visibility.hpp>
8 
9 #include <ngraph/pass/graph_rewrite.hpp>
10 
11 namespace ngraph {
12 namespace pass {
13 
14 class TRANSFORMATIONS_API SoftmaxFusion;
15 
16 } // namespace pass
17 } // namespace ngraph
18 
19 /**
20  * @ingroup ie_transformation_common_api
21  * @brief SoftmaxFusion transformation replaces following graph:
22  *
23  * +---------------+
24  * │ │
25  * │ input │
26  * │ │
27  * +---------------+
28  * │ │
29  * │ v
30  * │ +-----------+
31  * │ │ │
32  * │ │ ReduceMax │
33  * │ │ │
34  * │ +-----------+
35  * │ │
36  * │ │
37  * v v
38  * +---------------+
39  * │ │
40  * │ Sub │
41  * │ │
42  * +---------------+
43  * |
44  * |
45  * v
46  * +---------------+
47  * │ │
48  * │ Exp │
49  * │ │
50  * +---------------+
51  * │ │
52  * │ v
53  * │ +-----------+
54  * │ │ │
55  * │ │ ReduceSum │
56  * │ │ │
57  * │ +-----------+
58  * │ │
59  * │ │
60  * v v
61  * +-------------+
62  * | │
63  * | Div │
64  * │ │
65  * +-------------+
66  *
67  * to a single Softmax node
68  *
69  * * Restrictions:
70  * - ReduceMax and ReduceSum axes must be scalar constants and they have to point to the same axis
71  */
72 
73 class ngraph::pass::SoftmaxFusion: public ngraph::pass::MatcherPass {
74 public:
75  NGRAPH_RTTI_DECLARATION;
76  SoftmaxFusion();
77 };
SoftmaxFusion transformation replaces following graph:
Definition: softmax_fusion.hpp:73
ngraph namespace
Definition: add_fake_quantize_fusion.hpp:14