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

            Line data    Source code
       1              : // SPDX-License-Identifier: Apache-2.0
       2              : /**
       3              :  * Copyright (C) 2020 Jihoon Lee <jhoon.it.lee@samsung.com>
       4              :  *
       5              :  * @file   plugged_layer.h
       6              :  * @date   27 January 2021
       7              :  * @brief  This file contains a wrapper for a plugged layer, INTERNAL USE ONLY
       8              :  * @see    https://github.com/nnstreamer/nntrainer
       9              :  * @author Jihoon Lee <jhoon.it.lee@samsung.com>
      10              :  * @bug    No known bugs except for NYI items
      11              :  *
      12              :  */
      13              : 
      14              : #ifndef __PLUGGED_LAYER_H__
      15              : #define __PLUGGED_LAYER_H__
      16              : 
      17              : #include <layer_context.h>
      18              : #include <layer_devel.h>
      19              : #include <nntrainer_error.h>
      20              : 
      21              : namespace nntrainer {
      22              : namespace internal {
      23              : 
      24              : /**
      25              :  * @brief PluggedLayer to wrap a layer from shared object file
      26              :  *
      27              :  */
      28              : class PluggedLayer : public nntrainer::Layer {
      29              : public:
      30              :   /**
      31              :    * @brief Construct a new Plugged Layer object
      32              :    *
      33              :    * @param pluggable LayerPluggable structure from the symbol
      34              :    */
      35            6 :   PluggedLayer(const nntrainer::LayerPluggable *pluggable) :
      36           12 :     layerImpl(pluggable->createfunc()),
      37            6 :     destroy_func(pluggable->destroyfunc) {
      38            6 :     NNTR_THROW_IF(layerImpl == nullptr, std::invalid_argument)
      39              :       << "either create_func_ failed or cannot dynamic cast to layer";
      40            6 :   }
      41              : 
      42              :   /**
      43              :    * @brief Destroy the Plugged Layer object
      44              :    *
      45              :    */
      46            6 :   ~PluggedLayer() override { destroy_func(layerImpl); }
      47              : 
      48              :   /**
      49              :    * @brief Move Contruct Plugged Layer object
      50              :    *
      51              :    * @param rhs layer to move
      52              :    */
      53              :   PluggedLayer(PluggedLayer &&rhs) noexcept = default;
      54              : 
      55              :   /**
      56              :    * @brief Move assign Plugged Layer Object
      57              :    *
      58              :    * @param rhs layer to move
      59              :    * @return PluggedLayer& *this
      60              :    */
      61              :   PluggedLayer &operator=(PluggedLayer &&rhs) = default;
      62              : 
      63              :   /**
      64              :    * @copydoc Layer::getType()
      65              :    */
      66            6 :   const std::string getType() const override { return layerImpl->getType(); }
      67              : 
      68              :   /**
      69              :    * @copydoc Layer::finalize(InitLayerContext &context)
      70              :    */
      71            0 :   void finalize(InitLayerContext &context) override {
      72            0 :     layerImpl->finalize(context);
      73            0 :   }
      74              : 
      75              :   /**
      76              :    * @copydoc Layer::forwarding(RunLayerContext &context, bool training)
      77              :    */
      78            0 :   void forwarding(RunLayerContext &context, bool training) override {
      79            0 :     layerImpl->forwarding(context, training);
      80            0 :   }
      81              : 
      82              :   /**
      83              :    * @copydoc Layer::calcDerivative(RunLayerContext &context)
      84              :    */
      85            0 :   void calcDerivative(RunLayerContext &context) override {
      86            0 :     layerImpl->calcDerivative(context);
      87            0 :   }
      88              : 
      89              :   /**
      90              :    * @copydoc Layer::calcGradient(RunLayerContext &context)
      91              :    */
      92            0 :   void calcGradient(RunLayerContext &context) override {
      93            0 :     layerImpl->calcGradient(context);
      94            0 :   }
      95              : 
      96              :   /**
      97              :    * @copydoc Layer::setProperty(const PropertyType type, const std::string
      98              :    * &value)
      99              :    */
     100            0 :   void setProperty(const std::vector<std::string> &values) override {
     101            0 :     layerImpl->setProperty(values);
     102            0 :   }
     103              : 
     104              :   /**
     105              :    * @copydoc Layer::exportTo(Exporter &exporter, ml::train::ExportMethods
     106              :    * method)
     107              :    */
     108            0 :   void exportTo(Exporter &exporter,
     109              :                 const ml::train::ExportMethods &method) const override {
     110            0 :     layerImpl->exportTo(exporter, method);
     111            0 :   }
     112              : 
     113              :   /**
     114              :    * @copydoc Layer::setBatch(RunLayerContext &context, unsigned int batch)
     115              :    */
     116            0 :   void setBatch(RunLayerContext &context, unsigned int batch) override {
     117            0 :     layerImpl->setBatch(context, batch);
     118            0 :   }
     119              : 
     120              :   /**
     121              :    * @copydoc Layer::supportInPlace()
     122              :    */
     123            0 :   bool supportInPlace() const override { return layerImpl->supportInPlace(); }
     124              : 
     125              :   /**
     126              :    * @copydoc Layer::requireLabel()
     127              :    */
     128            0 :   bool requireLabel() const override { return layerImpl->requireLabel(); }
     129              : 
     130              :   /**
     131              :    * @copydoc Layer::supportBackwarding()
     132              :    */
     133            0 :   bool supportBackwarding() const override {
     134            0 :     return layerImpl->supportBackwarding();
     135              :   }
     136              : 
     137              : private:
     138              :   nntrainer::Layer *layerImpl;
     139              :   nntrainer::DestroyLayerFunc destroy_func;
     140              : };
     141              : } // namespace internal
     142              : } // namespace nntrainer
     143              : 
     144              : #endif // __PLUGGED_LAYER_H__
        

Generated by: LCOV version 2.0-1