LCOV - code coverage report
Current view: top level - nntrainer/compiler - remap_realizer.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 21 21
Test Date: 2025-12-14 20:38:17 Functions: 100.0 % 5 5

            Line data    Source code
       1              : // SPDX-License-Identifier: Apache-2.0
       2              : /**
       3              :  * Copyright (C) 2021 Jihoon Lee <jhoon.it.lee@samsung.com>
       4              :  *
       5              :  * @file remap_realizer.h
       6              :  * @date 12 October 2021
       7              :  * @brief NNTrainer graph realizer which realizes identifier to a new identifier
       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              : #include <remap_realizer.h>
      13              : 
      14              : #include <layer_node.h>
      15              : namespace nntrainer {
      16              : 
      17         2926 : RemapRealizer::RemapRealizer(
      18         2926 :   std::function<void(std::string &, unsigned &)> remap_connection_function) :
      19              :   remap_fn(nullptr),
      20         2926 :   remap_connection_fn(remap_connection_function) {
      21         2926 :   if (!remap_connection_fn) {
      22            1 :     throw std::invalid_argument("remap function is not given!");
      23              :   }
      24         2925 : }
      25              : 
      26          112 : RemapRealizer::RemapRealizer(
      27          112 :   std::function<void(std::string &)> remap_function) :
      28          112 :   remap_fn(remap_function),
      29          112 :   remap_connection_fn(nullptr) {
      30          112 :   if (!remap_fn) {
      31            1 :     throw std::invalid_argument("remap function is not given!");
      32              :   }
      33          111 : }
      34              : 
      35         3088 : RemapRealizer::~RemapRealizer() {}
      36              : 
      37              : GraphRepresentation
      38         3036 : RemapRealizer::realize(const GraphRepresentation &reference) {
      39         3036 :   GraphRepresentation processed(reference.begin(), reference.end());
      40              : 
      41        22159 :   for (auto &node : processed) {
      42              :     /// @note while remap realization, the graph is invalid.
      43        38249 :     remap_connection_fn ? node->remapConnections(remap_connection_fn)
      44        19488 :                         : node->remapIdentifiers(remap_fn);
      45              :   }
      46         3033 :   return processed;
      47            3 : }
      48              : 
      49              : } // namespace nntrainer
        

Generated by: LCOV version 2.0-1