Line data Source code
1 : /**
2 : * Copyright (C) 2020 Samsung Electronics Co., Ltd. All Rights Reserved.
3 : *
4 : * Licensed under the Apache License, Version 2.0 (the "License");
5 : * you may not use this file except in compliance with the License.
6 : * You may obtain a copy of the License at
7 : * http://www.apache.org/licenses/LICENSE-2.0
8 : * Unless required by applicable law or agreed to in writing, software
9 : * distributed under the License is distributed on an "AS IS" BASIS,
10 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 : * See the License for the specific language governing permissions and
12 : * limitations under the License.
13 : *
14 : * @file input_layer.h
15 : * @date 14 May 2020
16 : * @brief This is Input Layer Class of Neural Network
17 : * @see https://github.com/nnstreamer/nntrainer
18 : * @author Jijoong Moon <jijoong.moon@samsung.com>
19 : * @bug No known bugs except for NYI items
20 : *
21 : */
22 :
23 : #ifndef __INPUT_LAYER_H__
24 : #define __INPUT_LAYER_H__
25 : #ifdef __cplusplus
26 :
27 : #include <common_properties.h>
28 : #include <layer_devel.h>
29 :
30 : namespace nntrainer {
31 :
32 : /**
33 : * @class Input Layer
34 : * @note input layers requires to be only single input, consider making the
35 : * class deal with multiple inputs
36 : * @brief Just Handle the Input of Network
37 : */
38 : class InputLayer : public Layer {
39 : public:
40 : /**
41 : * @brief Constructor of InputLayer
42 : */
43 : InputLayer();
44 :
45 : /**
46 : * @brief Destructor of InputLayer
47 : */
48 1432 : ~InputLayer() = default;
49 :
50 : /**
51 : * @brief Move constructor of Pooling 2D Layer.
52 : * @param[in] Input &&
53 : */
54 : InputLayer(InputLayer &&rhs) noexcept = default;
55 :
56 : /**
57 : * @brief Move assignment operator.
58 : * @parma[in] rhs InputLayer to be moved.
59 : */
60 : InputLayer &operator=(InputLayer &&rhs) = default;
61 :
62 : /**
63 : * @copydoc Layer::finalize(InitLayerContext &context)
64 : */
65 : void finalize(InitLayerContext &context) override;
66 :
67 : /**
68 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
69 : */
70 : void forwarding(RunLayerContext &context, bool training) override;
71 :
72 : /**
73 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
74 : */
75 : void calcDerivative(RunLayerContext &context) override;
76 :
77 : /**
78 : * @copydoc bool supportBackwarding() const
79 : */
80 2 : bool supportBackwarding() const override { return false; };
81 :
82 : /**
83 : * @brief Initialize the in-place settings of the layer
84 : * @return InPlaceType
85 : */
86 536 : InPlaceType initializeInPlace() final {
87 536 : is_inplace = true;
88 536 : return InPlaceType::NON_RESTRICTING;
89 : }
90 :
91 : /**
92 : * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
93 : * method)
94 : */
95 : void exportTo(Exporter &exporter,
96 : const ml::train::ExportMethods &method) const override;
97 :
98 : /**
99 : * @copydoc Layer::getType()
100 : */
101 28559 : const std::string getType() const override { return InputLayer::type; };
102 :
103 : /**
104 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
105 : */
106 : void setProperty(const std::vector<std::string> &values) override;
107 :
108 : void updateTensorsByInputDimensions(
109 : nntrainer::RunLayerContext &context,
110 : std::vector<nntrainer::TensorDim> input_dimensions) override;
111 :
112 : static constexpr const char *type = "input";
113 :
114 : private:
115 : std::tuple<props::Normalization, props::Standardization> input_props;
116 : };
117 : } // namespace nntrainer
118 :
119 : #endif /* __cplusplus */
120 : #endif /* __INPUT_LAYER_H__ */
|