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

            Line data    Source code
       1              : // SPDX-License-Identifier: Apache-2.0
       2              : /**
       3              :  * Copyright (C) 2025 SeungBaek Hong <sb92.hong@samsung.com>
       4              :  *
       5              :  * @file   sine_layer.h
       6              :  * @date   19 March 2025
       7              :  * @see    https://github.com/nnstreamer/nntrainer
       8              :  * @author SeungBaek Hong <sb92.hong@samsung.com>
       9              :  * @bug    No known bugs except for NYI items
      10              :  * @brief  This is sine layer class (operation layer)
      11              :  *
      12              :  */
      13              : 
      14              : #ifndef __SINE_LAYER_H__
      15              : #define __SINE_LAYER_H__
      16              : #ifdef __cplusplus
      17              : 
      18              : #include <common_properties.h>
      19              : #include <layer_devel.h>
      20              : #include <operation_layer.h>
      21              : 
      22              : namespace nntrainer {
      23              : 
      24              : /**
      25              :  * @class Sine Layer
      26              :  * @brief Sine Layer
      27              :  */
      28              : class SineLayer : public UnaryOperationLayer {
      29              : public:
      30              :   /**
      31              :    * @brief Constructor of Sine Layer
      32              :    */
      33           40 :   SineLayer() :
      34              :     UnaryOperationLayer(),
      35           80 :     sine_props(props::Print(), props::InPlaceProp()),
      36           40 :     support_backwarding(true) {}
      37              : 
      38              :   /**
      39              :    * @brief Destructor of Sine Layer
      40              :    */
      41           40 :   ~SineLayer(){};
      42              : 
      43              :   /**
      44              :    *  @brief  Move constructor of Sine Layer.
      45              :    *  @param[in] SineLayer &&
      46              :    */
      47              :   SineLayer(SineLayer &&rhs) noexcept = default;
      48              : 
      49              :   /**
      50              :    * @brief  Move assignment operator.
      51              :    * @parma[in] rhs SineLayer to be moved.
      52              :    */
      53              :   SineLayer &operator=(SineLayer &&rhs) = default;
      54              : 
      55              :   /**
      56              :    * @copydoc Layer::finalize(InitLayerContext &context)
      57              :    */
      58              :   void finalize(InitLayerContext &context) final;
      59              : 
      60              :   /**
      61              :    * @brief forwarding operation for sine
      62              :    *
      63              :    * @param input input tensor
      64              :    * @param hidden tensor to store the result value
      65              :    */
      66              :   void forwarding_operation(const Tensor &input, Tensor &hidden) final;
      67              : 
      68              :   /**
      69              :    * @copydoc Layer::calcDerivative(RunLayerContext &context)
      70              :    */
      71              :   void calcDerivative(RunLayerContext &context) final;
      72              : 
      73              :   /**
      74              :    * @copydoc bool supportBackwarding() const
      75              :    */
      76           14 :   bool supportBackwarding() const final { return support_backwarding; };
      77              : 
      78              :   /**
      79              :    * @brief Initialize the in-place settings of the layer
      80              :    * @return InPlaceType
      81              :    */
      82            2 :   InPlaceType initializeInPlace() final {
      83              :     auto inplace_prop = std::get<props::InPlaceProp>(sine_props);
      84            2 :     is_inplace = !inplace_prop.empty() && inplace_prop.get();
      85            2 :     support_backwarding = !is_inplace;
      86            4 :     return supportInPlace() ? InPlaceType::NON_RESTRICTING : InPlaceType::NONE;
      87              :   }
      88              : 
      89              :   /**
      90              :    * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
      91              :    * method)
      92              :    */
      93            2 :   void exportTo(Exporter &exporter,
      94            2 :                 const ml::train::ExportMethods &method) const final {}
      95              : 
      96              :   /**
      97              :    * @copydoc Layer::setProperty(const std::vector<std::string> &values)
      98              :    */
      99              :   void setProperty(const std::vector<std::string> &values) final;
     100              : 
     101              :   /**
     102              :    * @copydoc Layer::getType()
     103              :    */
     104          130 :   const std::string getType() const final { return SineLayer::type; };
     105              : 
     106              :   std::tuple<props::Print, props::InPlaceProp> sine_props;
     107              :   bool support_backwarding; /**< support backwarding */
     108              : 
     109              :   inline static const std::string type = "sin";
     110              : };
     111              : 
     112              : } // namespace nntrainer
     113              : 
     114              : #endif /* __cplusplus */
     115              : #endif /* __SINE_LAYER_H__ */
        

Generated by: LCOV version 2.0-1