Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2025 Jijoong Moon <jijoong.moon@samsung.com>
4 : *
5 : * @file TensorLayer.h
6 : * @date 17 Jan 2025
7 : * @brief This is QNN Tensor Layer Class of Neural Network
8 : * @see https://github.com/nnstreamer/nntrainer
9 : * @author Jijoong Moon <jijoong.moon@samsung.com>
10 : * @bug No known bugs except for NYI items
11 : *
12 : */
13 :
14 : #ifndef __TENSOR_LAYER_H__
15 : #define __TENSOR_LAYER_H__
16 : #ifdef __cplusplus
17 :
18 : #include <common_properties.h>
19 : #include <layer_devel.h>
20 :
21 : namespace nntrainer {
22 :
23 : /**
24 : * @class Input Layer
25 : * @note input layers requires to be only single input, consider making the
26 : * class deal with multiple inputs
27 : * @brief Just Handle the Input of Network
28 : */
29 : class TensorLayer : public Layer {
30 : public:
31 : /**
32 : * @brief Constructor of TensorLayer
33 : */
34 : TensorLayer();
35 :
36 : /**
37 : * @brief Destructor of TensorLayer
38 : */
39 0 : ~TensorLayer() = default;
40 :
41 : /**
42 : * @brief Move constructor of Pooling 2D Layer.
43 : * @param[in] Input &&
44 : */
45 : TensorLayer(TensorLayer &&rhs) noexcept = default;
46 :
47 : /**
48 : * @brief Move assignment operator.
49 : * @parma[in] rhs TensorLayer to be moved.
50 : */
51 : TensorLayer &operator=(TensorLayer &&rhs) = default;
52 :
53 : /**
54 : * @copydoc Layer::finalize(InitLayerContext &context)
55 : */
56 : void finalize(InitLayerContext &context) override;
57 :
58 : /**
59 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
60 : */
61 : void forwarding(RunLayerContext &context, bool training) override;
62 :
63 : /**
64 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
65 : */
66 : void calcDerivative(RunLayerContext &context) override;
67 :
68 : /**
69 : * @copydoc bool supportBackwarding() const
70 : */
71 0 : bool supportBackwarding() const override { return false; };
72 :
73 : /**
74 : * @brief Initialize the in-place settings of the layer
75 : * @return InPlaceType
76 : */
77 0 : InPlaceType initializeInPlace() final {
78 0 : is_inplace = true;
79 0 : return InPlaceType::NON_RESTRICTING;
80 : }
81 :
82 : /**
83 : * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
84 : * method)
85 : */
86 : void exportTo(Exporter &exporter,
87 : const ml::train::ExportMethods &method) const override;
88 :
89 : /**
90 : * @copydoc Layer::getType()
91 : */
92 0 : const std::string getType() const override { return TensorLayer::type; };
93 :
94 : /**
95 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
96 : */
97 : void setProperty(const std::vector<std::string> &values) override;
98 :
99 : inline static const std::string type = "tensor";
100 :
101 : private:
102 : std::tuple<std::vector<props::TensorDimension>,
103 : std::vector<props::TensorDataType>, std::vector<props::TensorName>,
104 : std::vector<props::TensorLife>>
105 : tensor_props;
106 :
107 : std::vector<unsigned int> tensor_idx;
108 : unsigned int n_tensor;
109 : };
110 : } // namespace nntrainer
111 :
112 : #endif /* __cplusplus */
113 : #endif /* __INPUT_LAYER_H__ */
|