Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2024 heka1024 <heka1024@gmail.com>
4 : *
5 : * @file upsample2d_layer.h
6 : * @date 15 June 2024
7 : * @brief This is Upsample2d Layer Class of Neural Network
8 : * @see https://github.com/nnstreamer/nntrainer
9 : * @author heka1024 <heka1024@gmail.com>
10 : * @bug No known bugs except for NYI items
11 : *
12 : */
13 :
14 : #ifndef __UPSAMPLE2D_LAYER_H__
15 : #define __UPSAMPLE2D_LAYER_H__
16 : #ifdef __cplusplus
17 :
18 : #include <common_properties.h>
19 : #include <layer_impl.h>
20 :
21 : #include <node_exporter.h>
22 :
23 : namespace nntrainer {
24 :
25 : constexpr const unsigned int UPSAMPLE2D_DIM = 2;
26 :
27 : /**
28 : * @class Upsample2dLayer
29 : * @brief Upsamle 2d layer
30 : */
31 : class Upsample2dLayer : public Layer {
32 : public:
33 : /**
34 : * @brief Construct a new Upsample layer object
35 : *
36 : */
37 : Upsample2dLayer();
38 :
39 : /**
40 : * @brief Destroy the Upsample layer object
41 : *
42 : */
43 23 : ~Upsample2dLayer() {}
44 :
45 : /**
46 : * @copydoc Layer::finalize(InitLayerContext &context)
47 : */
48 : void finalize(nntrainer::InitLayerContext &context) override;
49 :
50 : /**
51 : * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
52 : */
53 : void forwarding(nntrainer::RunLayerContext &context, bool training) override;
54 :
55 : /**
56 : * @copydoc Layer::calcDerivative(RunLayerContext &context)
57 : */
58 : void calcDerivative(nntrainer::RunLayerContext &context) override;
59 :
60 : /**
61 : * @copydoc bool supportBackwarding() const
62 : */
63 2 : bool supportBackwarding() const override { return true; };
64 :
65 : /**
66 : * @copydoc Layer::exportTo(Exporter &exporter, ExportMethods method)
67 : */
68 0 : void exportTo(nntrainer::Exporter &exporter,
69 0 : const ml::train::ExportMethods &method) const override{};
70 :
71 : /**
72 : * @copydoc Layer::getType()
73 : */
74 31 : const std::string getType() const override { return Upsample2dLayer::type; };
75 :
76 : /**
77 : * @copydoc Layer::setProperty(const std::vector<std::string> &values)
78 : */
79 : void setProperty(const std::vector<std::string> &values) override;
80 :
81 : static constexpr const char *type = "upsample2d";
82 :
83 : private:
84 : std::tuple<props::UpsampleMode, std::array<props::KernelSize, UPSAMPLE2D_DIM>>
85 : upsample2d_props; /* mode, size of kernel */
86 : };
87 : } // namespace nntrainer
88 :
89 : #endif /* __cplusplus */
90 : #endif /* __UPSAMPLE2D_LAYER_H__ */
|