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

            Line data    Source code
       1              : // SPDX-License-Identifier: Apache-2.0
       2              : /**
       3              :  * Copyright (C) 2024 SeungBaek Hong <sb92.hong@samsung.com>
       4              :  *
       5              :  * @file   weight_layer.h
       6              :  * @date   2 August 2024
       7              :  * @brief  This is a layer that simply stores a weight tensor without any
       8              :  * operation.
       9              :  * @see    https://github.com/nnstreamer/nntrainer
      10              :  * @author SeungBaek Hong <sb92.hong@samsung.com>
      11              :  * @bug    No known bugs except for NYI items
      12              :  *
      13              :  */
      14              : 
      15              : #ifndef __WEIGHT_LAYER_H__
      16              : #define __WEIGHT_LAYER_H__
      17              : #ifdef __cplusplus
      18              : 
      19              : #include <common_properties.h>
      20              : #include <layer_impl.h>
      21              : 
      22              : namespace nntrainer {
      23              : 
      24              : /**
      25              :  * @class   Weight Layer
      26              :  * @brief   A layer that simply stores a weight tensor
      27              :  */
      28              : class WeightLayer : public LayerImpl {
      29              : public:
      30              :   /**
      31              :    * @brief     Constructor of Weight Layer
      32              :    */
      33              :   WeightLayer();
      34              : 
      35              :   /**
      36              :    * @brief     Destructor of Weight Layer
      37              :    */
      38           74 :   ~WeightLayer() = default;
      39              : 
      40              :   /**
      41              :    *  @brief  Move constructor.
      42              :    *  @param[in] WeightLayer &&
      43              :    */
      44              :   WeightLayer(WeightLayer &&rhs) noexcept = default;
      45              : 
      46              :   /**
      47              :    * @brief  Move assignment operator.
      48              :    * @parma[in] rhs WeightLayer to be moved.
      49              :    */
      50              :   WeightLayer &operator=(WeightLayer &&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 Layer::calcGradient(RunLayerContext &context)
      69              :    */
      70              :   void calcGradient(RunLayerContext &context) override;
      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::getType()
      81              :    */
      82           45 :   const std::string getType() const override { return WeightLayer::type; };
      83              : 
      84              :   /**
      85              :    * @copydoc Layer::supportBackwarding()
      86              :    */
      87            4 :   bool supportBackwarding() const override { return false; }
      88              : 
      89              :   /**
      90              :    * @copydoc Layer::setProperty(const PropertyType type, const std::string
      91              :    * &value)
      92              :    */
      93              :   void setProperty(const std::vector<std::string> &values) override;
      94              : 
      95              :   static constexpr const char *type = "weight";
      96              : 
      97              : private:
      98              :   std::tuple<props::TensorDimension, props::TensorDataType, props::WeightName>
      99              :     weight_props;
     100              :   unsigned int weight_idx;
     101              : };
     102              : } // namespace nntrainer
     103              : 
     104              : #endif /* __cplusplus */
     105              : #endif /* __WEIGHT_LAYER_H__ */
        

Generated by: LCOV version 2.0-1