LCOV - code coverage report
Current view: top level - nntrainer/layers - conv2d_transpose_layer.h (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 0.0 % 4 0
Test Date: 2025-12-14 20:38:17 Functions: 0.0 % 4 0

            Line data    Source code
       1              : // SPDX-License-Identifier: Apache-2.0
       2              : /**
       3              :  * Copyright (C) 2024 UGyeong Song <thddnrud@snu.ac.kr>
       4              :  *
       5              :  * @file   conv2d_transpose_layer.h
       6              :  * @date   13 October 2024
       7              :  * @see    https://github.com/nnstreamer/nntrainer
       8              :  * @author UGyeong Song <thddnrud@snu.ac.kr>
       9              :  * @bug    No known bugs except for NYI items
      10              :  * @brief  This is Transposed Convolution Layer Class for Neural Network
      11              :  *
      12              :  */
      13              : 
      14              : #ifndef __CONV2D_TRANSPOSE_LAYER_H_
      15              : #define __CONV2D_TRANSPOSE_LAYER_H_
      16              : #ifdef __cplusplus
      17              : 
      18              : #include <memory.h>
      19              : 
      20              : #include <common_properties.h>
      21              : #include <layer_impl.h>
      22              : 
      23              : namespace nntrainer {
      24              : 
      25              : constexpr const unsigned int CONV2D_TRANSPOSE_DIM = 2;
      26              : 
      27              : /**
      28              :  * @class   Convolution 2D Transpose Layer
      29              :  * @brief   Convolution 2D Transpose Layer
      30              :  */
      31              : class Conv2DTransposeLayer : public LayerImpl {
      32              : public:
      33              :   /**
      34              :    * @brief     Constructor of Conv 2D Transpose Layer
      35              :    */
      36              :   Conv2DTransposeLayer(const std::array<unsigned int, CONV2D_TRANSPOSE_DIM * 2>
      37              :                          &padding_ = {0, 0, 0, 0});
      38              : 
      39              :   /**
      40              :    * @brief     Destructor of Conv 2D Transpose Layer
      41              :    */
      42            0 :   ~Conv2DTransposeLayer() = default;
      43              : 
      44              :   /**
      45              :    *  @brief  Move constructor of Conv 2D Transpose Layer.
      46              :    *  @param[in] Conv2dTransposeLayer &&
      47              :    */
      48              :   Conv2DTransposeLayer(Conv2DTransposeLayer &&rhs) noexcept = default;
      49              : 
      50              :   /**
      51              :    * @brief  Move assignment operator.
      52              :    * @parma[in] rhs Conv2DTransposeLayer to be moved.
      53              :    */
      54              :   Conv2DTransposeLayer &operator=(Conv2DTransposeLayer &&rhs) = default;
      55              : 
      56              :   /**
      57              :    * @copydoc Layer::finalize(InitLayerContext &context)
      58              :    */
      59              :   void finalize(InitLayerContext &context) override;
      60              : 
      61              :   /**
      62              :    * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
      63              :    */
      64              :   void forwarding(RunLayerContext &context, bool training) override;
      65              : 
      66              :   /**
      67              :    * @copydoc Layer::calcDerivative(RunLayerContext &context)
      68              :    */
      69              :   void calcDerivative(RunLayerContext &context) override;
      70              : 
      71              :   /**
      72              :    * @copydoc Layer::calcGradient(RunLayerContext &context)
      73              :    */
      74              :   void calcGradient(RunLayerContext &context) override;
      75              : 
      76              :   /**
      77              :    * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
      78              :    * method)
      79              :    */
      80              :   void exportTo(Exporter &exporter,
      81              :                 const ml::train::ExportMethods &method) const override;
      82              : 
      83              :   /**
      84              :    * @copydoc Layer::getType()
      85              :    */
      86            0 :   const std::string getType() const override {
      87            0 :     return Conv2DTransposeLayer::type;
      88              :   };
      89              : 
      90              :   /**
      91              :    * @copydoc Layer::supportBackwarding()
      92              :    */
      93            0 :   bool supportBackwarding() const override { return true; }
      94              : 
      95              :   using Layer::setProperty;
      96              : 
      97              :   /**
      98              :    * @copydoc Layer::setProperty(const PropertyType type, const std::string
      99              :    * &value)
     100              :    */
     101              :   void setProperty(const std::vector<std::string> &values) override;
     102              : 
     103              :   /* TO DO : support keras type of padding */
     104              :   /* enum class PaddingType { */
     105              :   /*   full = 0, */
     106              :   /*   same = 1, */
     107              :   /*   valid = 2, */
     108              :   /*   unknown = 3, */
     109              :   /* }; */
     110              : 
     111              :   static constexpr const char *type = "conv2dtranspose";
     112              : 
     113              : private:
     114              :   std::array<unsigned int, CONV2D_TRANSPOSE_DIM * 2> padding;
     115              :   std::tuple<props::FilterSize,
     116              :              std::array<props::KernelSize, CONV2D_TRANSPOSE_DIM>,
     117              :              std::array<props::Stride, CONV2D_TRANSPOSE_DIM>, props::Padding2D,
     118              :              std::array<props::Dilation, CONV2D_TRANSPOSE_DIM>>
     119              :     conv_props;
     120              : 
     121              :   std::array<unsigned int, 5> wt_idx; /**< indices of the weights and tensors */
     122              : };
     123              : 
     124              : } // namespace nntrainer
     125              : 
     126              : #endif /* __cplusplus */
     127              : #endif /* __CONV2D_TRANSPOSE_LAYER_H__ */
        

Generated by: LCOV version 2.0-1