gelu_fusion.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <memory>
8 #include <ngraph/pass/graph_rewrite.hpp>
9 #include <transformations_visibility.hpp>
10 #include <utility>
11 
12 namespace ngraph {
13 namespace pass {
14 
15 class TRANSFORMATIONS_API GeluFusion;
16 class TRANSFORMATIONS_API GeluFusionWithErfOne;
17 class TRANSFORMATIONS_API GeluFusionWithErfTwo;
18 class TRANSFORMATIONS_API GeluFusionWithErfThree;
19 
20 } // namespace pass
21 } // namespace ngraph
22 
23 /**
24  * @ingroup ie_transformation_common_api
25  * @brief GeluFusion transformation replaces a sub-graph
26  * (0.5 * x) * (1 + erf(x / sqrt(2))) with a Gelu op.
27  */
28 class ngraph::pass::GeluFusionWithErfOne : public ngraph::pass::MatcherPass {
29 public:
30  NGRAPH_RTTI_DECLARATION;
32 };
33 
34 /**
35  * @ingroup ie_transformation_common_api
36  * @brief GeluFusion transformation replaces a sub-graph
37  * 0.5 * (x * (1 + erf(x / sqrt(2))) with a Gelu op.
38  */
39 class ngraph::pass::GeluFusionWithErfTwo : public ngraph::pass::MatcherPass {
40 public:
41  NGRAPH_RTTI_DECLARATION;
43 };
44 
45 /**
46  * @ingroup ie_transformation_common_api
47  * @brief GeluFusion transformation replaces a sub-graph
48  * x * (0.5 * (1 + erf(x / sqrt(2))) with a Gelu op.
49  */
50 class ngraph::pass::GeluFusionWithErfThree : public ngraph::pass::MatcherPass {
51 public:
52  NGRAPH_RTTI_DECLARATION;
54 };
55 
56 /**
57  * @ingroup ie_transformation_common_api
58  * @brief GeluFusion transformation replaces various sub-graphs with a Gelu op.
59  */
60 class ngraph::pass::GeluFusion : public ngraph::pass::GraphRewrite {
61 public:
62  NGRAPH_RTTI_DECLARATION;
63  GeluFusion() {
64  add_matcher<ngraph::pass::GeluFusionWithErfOne>();
65  add_matcher<ngraph::pass::GeluFusionWithErfTwo>();
66  add_matcher<ngraph::pass::GeluFusionWithErfThree>();
67  }
68 };
GeluFusion transformation replaces a sub-graph (0.5 * x) * (1 + erf(x / sqrt(2))) with a Gelu op.
Definition: gelu_fusion.hpp:28
GeluFusion transformation replaces a sub-graph x * (0.5 * (1 + erf(x / sqrt(2))) with a Gelu op.
Definition: gelu_fusion.hpp:50
GeluFusion transformation replaces a sub-graph 0.5 * (x * (1 + erf(x / sqrt(2))) with a Gelu op.
Definition: gelu_fusion.hpp:39
GeluFusion transformation replaces various sub-graphs with a Gelu op.
Definition: gelu_fusion.hpp:60
ngraph namespace
Definition: add_fake_quantize_fusion.hpp:14