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 multiout_layer.h
6 : * @date 05 Nov 2020
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Jijoong Moon <jijoong.moon@samsung.com>
9 : * @bug No known bugs except for NYI items
10 : * @brief This is Multi Output Layer Class for Neural Network
11 : */
12 :
13 : #ifndef __MULTIOUT_LAYER_H__
14 : #define __MULTIOUT_LAYER_H__
15 : #ifdef __cplusplus
16 :
17 : #include <layer_devel.h>
18 :
19 : namespace nntrainer {
20 :
21 : /**
22 : * @class Multiout Layer
23 : * @brief Multiout Layer
24 : */
25 : class MultiOutLayer : public Layer {
26 : public:
27 : /**
28 : * @brief Constructor of Multiout Layer
29 : */
30 409 : MultiOutLayer() : Layer() {}
31 :
32 : /**
33 : * @brief Destructor of Multiout Layer
34 : */
35 409 : ~MultiOutLayer() = default;
36 :
37 : /**
38 : * @brief Move constructor of MultiOutLayer.
39 : * @param[in] MultiOutLayer &&
40 : */
41 : MultiOutLayer(MultiOutLayer &&rhs) noexcept = default;
42 :
43 : /**
44 : * @brief Move assignment operator.
45 : * @parma[in] rhs MultiOutLayer to be moved.
46 : */
47 : MultiOutLayer &operator=(MultiOutLayer &&rhs) = default;
48 :
49 : /**
50 : * @copydoc Layer::finalize(InitLayerContext &context)
51 : */
52 : void finalize(InitLayerContext &context) override;
53 :
54 : /**
55 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
56 : */
57 : void forwarding(RunLayerContext &context, bool training) override;
58 :
59 : /**
60 : * @copydoc Layer::incremental_forwarding(RunLayerContext &context, unsigned
61 : * int from, unsigned int to, bool training)
62 : */
63 : void incremental_forwarding(RunLayerContext &context, unsigned int from,
64 : unsigned int to, bool training) override;
65 :
66 : /**
67 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
68 : */
69 : void calcDerivative(RunLayerContext &context) override;
70 :
71 : /**
72 : * @copydoc bool supportBackwarding() const
73 : */
74 730 : bool supportBackwarding() const override { return true; };
75 :
76 : /**
77 : * @brief Initialize the in-place settings of the layer
78 : * @return InPlaceType
79 : */
80 194 : InPlaceType initializeInPlace() final {
81 194 : is_inplace = true;
82 194 : return InPlaceType::RESTRICTING;
83 : }
84 :
85 : /**
86 : * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
87 : * method)
88 : */
89 198 : void exportTo(Exporter &exporter,
90 198 : const ml::train::ExportMethods &method) const override {}
91 :
92 : /**
93 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
94 : */
95 : void setProperty(const std::vector<std::string> &values) override;
96 :
97 : /**
98 : * @copydoc Layer::getType()
99 : */
100 9507 : const std::string getType() const override { return MultiOutLayer::type; };
101 :
102 : void updateTensorsByInputDimensions(
103 : nntrainer::RunLayerContext &context,
104 : std::vector<nntrainer::TensorDim> input_dimensions) override;
105 :
106 : static constexpr const char *type = "multiout";
107 : };
108 :
109 : } // namespace nntrainer
110 :
111 : #endif /* __cplusplus */
112 : #endif /* __MULTIOUT_LAYER_H__ */
|