LCOV - code coverage report
Current view: top level - nntrainer/layers - divide_layer.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 % 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   divide_layer.cpp
       6              :  * @date   10 Oct 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 div layer class (operation layer)
      11              :  *
      12              :  */
      13              : 
      14              : #include <divide_layer.h>
      15              : #include <nntrainer_error.h>
      16              : #include <nntrainer_log.h>
      17              : #include <node_exporter.h>
      18              : #include <util_func.h>
      19              : 
      20              : #include <layer_context.h>
      21              : 
      22              : namespace nntrainer {
      23              : 
      24           12 : void DivideLayer::finalize(InitLayerContext &context) {
      25           12 :   context.setOutputDimensions({context.getInputDimensions()[0]});
      26           12 : }
      27              : 
      28            6 : void DivideLayer::forwarding_operation(const Tensor &input0,
      29              :                                        const Tensor &input1, Tensor &hidden) {
      30            6 :   input0.divide(input1, hidden);
      31            6 : }
      32              : 
      33            3 : void DivideLayer::calcDerivative(RunLayerContext &context) {
      34            6 :   context.getOutgoingDerivative(0).copy(
      35            6 :     context.getIncomingDerivative(SINGLE_INOUT_IDX)
      36            6 :       .divide(context.getInput(1)));
      37              : 
      38            6 :   context.getOutgoingDerivative(1).copy(
      39            3 :     context.getIncomingDerivative(SINGLE_INOUT_IDX)
      40            6 :       .multiply(context.getInput(0).multiply(-1))
      41            6 :       .divide(context.getInput(1).pow(2)));
      42            3 : }
      43              : 
      44           88 : void DivideLayer::setProperty(const std::vector<std::string> &values) {
      45           88 :   auto remain_props = loadProperties(values, divide_props);
      46           86 :   if (!remain_props.empty()) {
      47              :     std::string msg = "[DivideLayer] Unknown Layer Properties count " +
      48            4 :                       std::to_string(values.size());
      49            8 :     throw exception::not_supported(msg);
      50              :   }
      51           86 : }
      52              : } /* namespace nntrainer */
        

Generated by: LCOV version 2.0-1