LCOV - code coverage report
Current view: top level - nntrainer/optimizers - lr_scheduler_constant.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 100.0 % 14 14
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 Parichay Kapoor <pk.kapoor@samsung.com>
       4              :  *
       5              :  * @file   lr_scheduler_constant.cpp
       6              :  * @date   09 December 2021
       7              :  * @brief  This is Constant Learning Rate Scheduler class
       8              :  * @see    https://github.com/nnstreamer/nntrainer
       9              :  * @author Parichay Kapoor <pk.kapoor@samsung.com>
      10              :  * @bug    No known bugs except for NYI items
      11              :  *
      12              :  */
      13              : 
      14              : #include <cmath>
      15              : 
      16              : #include <common_properties.h>
      17              : #include <lr_scheduler_constant.h>
      18              : #include <nntrainer_error.h>
      19              : #include <nntrainer_log.h>
      20              : #include <node_exporter.h>
      21              : 
      22              : namespace nntrainer {
      23              : 
      24          650 : ConstantLearningRateScheduler::ConstantLearningRateScheduler() :
      25          650 :   lr_props(props::LearningRate()) {}
      26              : 
      27          619 : void ConstantLearningRateScheduler::finalize() {
      28          621 :   NNTR_THROW_IF(std::get<props::LearningRate>(lr_props).empty(),
      29              :                 std::invalid_argument)
      30              :     << "[ConstantLearningRateScheduler] Learning Rate is not set";
      31          617 : }
      32              : 
      33          840 : void ConstantLearningRateScheduler::setProperty(
      34              :   const std::vector<std::string> &values) {
      35          840 :   auto left = loadProperties(values, lr_props);
      36          841 :   NNTR_THROW_IF(left.size(), std::invalid_argument)
      37              :     << "[ConstantLearningRateScheduler] There are unparsed properties";
      38          834 : }
      39              : 
      40          240 : void ConstantLearningRateScheduler::exportTo(
      41              :   Exporter &exporter, const ml::train::ExportMethods &method) const {
      42          240 :   exporter.saveResult(lr_props, method, this);
      43          240 : }
      44              : 
      45        15550 : double ConstantLearningRateScheduler::getLearningRate(size_t iteration) {
      46        15550 :   return std::get<props::LearningRate>(lr_props);
      47              : }
      48              : 
      49              : } // namespace nntrainer
        

Generated by: LCOV version 2.0-1