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

            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   pow_layer.cpp
       6              :  * @date   20 Nov 2024
       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 pow layer class (operation layer)
      11              :  *
      12              :  */
      13              : 
      14              : #include "common_properties.h"
      15              : #include <nntrainer_error.h>
      16              : #include <nntrainer_log.h>
      17              : #include <node_exporter.h>
      18              : #include <pow_layer.h>
      19              : #include <util_func.h>
      20              : 
      21              : #include <layer_context.h>
      22              : 
      23              : namespace nntrainer {
      24              : 
      25           12 : void PowLayer::finalize(InitLayerContext &context) {
      26           12 :   context.setOutputDimensions({context.getInputDimensions()[0]});
      27           12 : }
      28              : 
      29            6 : void PowLayer::forwarding_operation(const Tensor &input, Tensor &hidden) {
      30            6 :   float exponent = std::get<props::Exponent>(pow_props).get();
      31            6 :   input.pow(exponent, hidden);
      32            6 : }
      33              : 
      34            3 : void PowLayer::calcDerivative(RunLayerContext &context) {
      35            3 :   float exp = std::get<props::Exponent>(pow_props).get();
      36            6 :   context.getOutgoingDerivative(0).copy(
      37            6 :     context.getIncomingDerivative(SINGLE_INOUT_IDX)
      38            3 :       .multiply(exp)
      39            6 :       .multiply(context.getInput(0).pow(exp - 1.0f)));
      40            3 : }
      41              : 
      42           88 : void PowLayer::setProperty(const std::vector<std::string> &values) {
      43           88 :   auto remain_props = loadProperties(values, pow_props);
      44           86 :   if (!remain_props.empty()) {
      45              :     std::string msg = "[PowLayer] Unknown Layer Properties count " +
      46            4 :                       std::to_string(values.size());
      47            8 :     throw exception::not_supported(msg);
      48              :   }
      49           86 : }
      50              : } /* namespace nntrainer */
        

Generated by: LCOV version 2.0-1