Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2020 Jijoong Moon <jijoong.moon@samsung.com>
4 : *
5 : * @file reshape_layer.h
6 : * @date 16 June 2020
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Parichay Kapoor <pk.kapoor@samsung.com>
9 : * @bug No known bugs except for NYI items
10 : * @brief This is Reshape Layer Class for Neural Network
11 : *
12 : */
13 :
14 : #ifndef __RESHAPE_LAYER_H__
15 : #define __RESHAPE_LAYER_H__
16 : #ifdef __cplusplus
17 :
18 : #include <common_properties.h>
19 : #include <layer_devel.h>
20 :
21 : namespace nntrainer {
22 :
23 : /**
24 : * @class Reshape Layer
25 : * @brief Reshape Layer
26 : */
27 : class ReshapeLayer : public Layer {
28 : public:
29 : /**
30 : * @brief Constructor of Reshape Layer
31 : */
32 183 : ReshapeLayer() : Layer() {}
33 :
34 : /**
35 : * @brief Destructor of Reshape Layer
36 : */
37 192 : ~ReshapeLayer() = default;
38 :
39 : /**
40 : * @brief Move constructor of ReshapeLayer.
41 : * @param[in] ReshapeLayer &&
42 : */
43 : ReshapeLayer(ReshapeLayer &&rhs) noexcept = default;
44 :
45 : /**
46 : * @brief Move assignment operator.
47 : * @parma[in] rhs ReshapeLayer to be moved.
48 : */
49 : ReshapeLayer &operator=(ReshapeLayer &&rhs) = default;
50 :
51 : /**
52 : * @copydoc Layer::finalize(InitLayerContext &context)
53 : */
54 : void finalize(InitLayerContext &context) override;
55 :
56 : /**
57 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
58 : */
59 : void forwarding(RunLayerContext &context, bool training) override;
60 :
61 : /**
62 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
63 : */
64 : void calcDerivative(RunLayerContext &context) override;
65 :
66 : /**
67 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
68 : */
69 : void setProperty(const std::vector<std::string> &values) override;
70 :
71 : /**
72 : * @copydoc bool supportBackwarding() const
73 : */
74 139 : bool supportBackwarding() const override { return true; };
75 :
76 : /**
77 : * @brief Initialize the in-place settings of the layer
78 : * @return InPlaceType
79 : */
80 47 : InPlaceType initializeInPlace() override {
81 47 : is_inplace = true;
82 47 : return InPlaceType::RESTRICTING;
83 : }
84 :
85 : /**
86 : * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
87 : * method)
88 : */
89 : void exportTo(Exporter &exporter,
90 : const ml::train::ExportMethods &method) const override;
91 :
92 : /**
93 : * @copydoc Layer::getType()
94 : */
95 166 : const std::string getType() const override { return ReshapeLayer::type; };
96 :
97 : static constexpr const char *type = "reshape";
98 :
99 : protected:
100 : std::tuple<props::TargetShape>
101 : reshape_props; /**< reshape properties : target_shape after reshape */
102 : };
103 :
104 : } // namespace nntrainer
105 :
106 : #endif /* __cplusplus */
107 : #endif /* __RESHAPE_LAYER_H__ */
|