Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2022 Jijoong Moon <jijoong.moon@samsung.com>
4 : *
5 : * @file bn_realizer.h
6 : * @date 13 April 2022
7 : * @brief NNTrainer graph realizer which remove batch normalization layer for
8 : * inference
9 : * @see https://github.com/nnstreamer/nntrainer
10 : * @author Jijoong Moon <jijoong.moon@samsung.com>
11 : * @bug No known bugs except for NYI items
12 : */
13 : #ifndef __BN_REALIZER_H__
14 : #define __BN_REALIZER_H__
15 :
16 : #include <memory>
17 : #include <string>
18 : #include <vector>
19 :
20 : #include <connection.h>
21 : #include <realizer.h>
22 :
23 : namespace nntrainer {
24 :
25 : /**
26 : * @brief Graph realizer class which removes batch normalization layer from the
27 : * graph
28 : * @note This assumes the number of input / output connection of batch
29 : * normalization layer == 1
30 : *
31 : */
32 : class BnRealizer final : public GraphRealizer {
33 : public:
34 : /**
35 : * @brief Construct a new BN Realizer object
36 : *
37 : */
38 : BnRealizer() = default;
39 :
40 : /**
41 : * @brief Destroy the Graph Realizer object
42 : *
43 : */
44 2 : ~BnRealizer() = default;
45 :
46 : /**
47 : * @brief graph realizer creates a shallow copied graph based on the reference
48 : * @note bn realizer removes batch normalization layers from
49 : * GraphRepresentation
50 : * @param reference GraphRepresentation to be realized
51 : * @throw std::invalid_argument if graph is ill formed
52 : *
53 : */
54 : GraphRepresentation realize(const GraphRepresentation &reference) override;
55 : };
56 :
57 : } // namespace nntrainer
58 :
59 : #endif // __BN_REALIZER_H__
|