Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2025 Sumon Nath <sumon.nath@samsung.com>
4 : *
5 : * @file reduce_sum_layer.h
6 : * @date 29 July 2025
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Sumon Nath <sumon.nath@samsung.com>
9 : * @bug No known bugs except for NYI items
10 : * @brief This is Reduce Sum Layer Class for Neural Network
11 : *
12 : */
13 :
14 : #ifndef __REDUCE_SUM_LAYER_H__
15 : #define __REDUCE_SUM_LAYER_H__
16 : #ifdef __cplusplus
17 :
18 : #include <common_properties.h>
19 : #include <layer_context.h>
20 : #include <layer_devel.h>
21 :
22 : namespace nntrainer {
23 :
24 : /**
25 : * @class Reduce Sum Layer
26 : * @brief Reduce Sum Layer
27 : */
28 : class ReduceSumLayer : public Layer {
29 : public:
30 : /**
31 : * @brief Constructor of Reduce Sum Layer
32 : */
33 22 : ReduceSumLayer() : Layer() {}
34 :
35 : /**
36 : * @brief Destructor of Reduce Sum Layer
37 : */
38 30 : ~ReduceSumLayer(){};
39 :
40 : /**
41 : * @brief Move constructor of ReduceSumLayer.
42 : * @param[in] ReduceSumLayer &&
43 : */
44 : ReduceSumLayer(ReduceSumLayer &&rhs) noexcept = default;
45 :
46 : /**
47 : * @brief Move assignment operator.
48 : * @parma[in] rhs ReduceSumLayer to be moved.
49 : */
50 : ReduceSumLayer &operator=(ReduceSumLayer &&rhs) = default;
51 :
52 : /**
53 : * @copydoc Layer::finalize(InitLayerContext &context)
54 : */
55 : void finalize(InitLayerContext &context) override;
56 :
57 : /**
58 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
59 : */
60 : void forwarding(RunLayerContext &context, bool training) override;
61 :
62 : /**
63 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
64 : */
65 : void calcDerivative(RunLayerContext &context) override;
66 :
67 : /**
68 : * @copydoc bool supportBackwarding() const
69 : */
70 12 : bool supportBackwarding() const override { return true; };
71 :
72 : /**
73 : * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
74 : * method)
75 : */
76 : void exportTo(Exporter &exporter,
77 : const ml::train::ExportMethods &method) const override;
78 :
79 : /**
80 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
81 : */
82 : void setProperty(const std::vector<std::string> &values) override;
83 :
84 : /**
85 : * @copydoc Layer::getType()
86 : */
87 109 : const std::string getType() const override { return ReduceSumLayer::type; };
88 :
89 : static constexpr const char *type = "reduce_sum";
90 :
91 : private:
92 : std::tuple<props::ReduceDimension>
93 : reduce_sum_props; /**< reduce_sum properties : axis to reduce along */
94 : };
95 :
96 : } // namespace nntrainer
97 :
98 : #endif /* __cplusplus */
99 : #endif /* __REDUCE_SUM_LAYER_H__ */
|