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

Generated by: LCOV version 2.0-1