LCOV - code coverage report
Current view: top level - Source/nnue - featureTransformer.hpp (source / functions) Coverage Total Hit
Test: coverage Lines: 100.0 % 9 9
Test Date: 2026-03-02 16:42:41 Functions: - 0 0

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include "definition.hpp"
       4              : 
       5              : #ifdef WITH_NNUE
       6              : 
       7              : #include "stackVector.hpp"
       8              : #include "inputLayer.hpp"
       9              : 
      10              : template<typename NT, bool Q> 
      11              : struct FeatureTransformer {
      12              : 
      13              :    const InputLayer<NT, inputLayerSize, firstInnerLayerSize, Q>* weights_;
      14              : 
      15              :    using BIT = typename Quantization<Q>::BIT;
      16              : 
      17              :    // active_ is always for input layer, so BIT shall be used
      18              :    StackVector<BIT, firstInnerLayerSize, Q> active_;
      19              : 
      20              :    const StackVector<BIT, firstInnerLayerSize, Q> & active() const { return active_; }
      21              : 
      22              :    FORCE_FINLINE void clear() {
      23      8634774 :       assert(weights_);
      24      8634774 :       active_.from(weights_->b);
      25              :    }
      26              : 
      27              :    FORCE_FINLINE void insert(const size_t idx) {
      28    517499686 :       assert(weights_);
      29    192506626 :       weights_->insertIdx(idx, active_);
      30    166672996 :    }
      31              : 
      32              :    FORCE_FINLINE void erase(const size_t idx) {
      33    342737228 :       assert(weights_);
      34    324993060 :       weights_->eraseIdx(idx, active_);
      35      9092801 :    }
      36              : 
      37         2366 :    FeatureTransformer(const InputLayer<NT, inputLayerSize, firstInnerLayerSize, Q>* src): weights_ {src} { clear(); }
      38              : 
      39              :    FeatureTransformer() = delete;
      40              : 
      41              : #ifdef DEBUG_NNUE_UPDATE
      42              :    bool operator==(const FeatureTransformer<NT, Q>& other) { return active_ == other.active_; }
      43              : 
      44              :    bool operator!=(const FeatureTransformer<NT, Q>& other) { return active_ != other.active_; }
      45              : #endif
      46              : };
      47              : 
      48              : #endif // WITH_NNUE
        

Generated by: LCOV version 2.0-1