LCOV - code coverage report
Current view: top level - ml - Pooling.cpp (source / functions) Hit Total Coverage
Test: test_coverage.info.cleaned Lines: 0 26 0.0 %
Date: 2022-07-06 02:47:47 Functions: 0 7 0.0 %

          Line data    Source code
       1             : #include "Pooling.h"
       2             : 
       3             : namespace elsa::ml
       4             : {
       5             :     template <typename data_t>
       6           0 :     Pooling<data_t>::Pooling(LayerType layerType, index_t poolingDimensions,
       7             :                              const IndexVector_t& poolSize, index_t strides, Padding padding,
       8             :                              const std::string& name)
       9             :         : Layer<data_t>(layerType, name, /* input dims */ static_cast<int>(poolingDimensions) + 1,
      10             :                         /* inputs */ 1),
      11             :           poolingDimensions_(poolingDimensions),
      12             :           poolSize_(poolSize),
      13             :           strides_(strides),
      14           0 :           padding_(padding)
      15             :     {
      16           0 :     }
      17             : 
      18             :     template <typename data_t>
      19           0 :     IndexVector_t Pooling<data_t>::getPoolSize() const
      20             :     {
      21           0 :         return poolSize_;
      22             :     }
      23             : 
      24             :     template <typename data_t>
      25           0 :     index_t Pooling<data_t>::getStrides() const
      26             :     {
      27           0 :         return strides_;
      28             :     }
      29             : 
      30             :     template <typename data_t>
      31           0 :     Padding Pooling<data_t>::getPadding() const
      32             :     {
      33           0 :         return padding_;
      34             :     }
      35             : 
      36             :     template <typename data_t>
      37           0 :     void Pooling<data_t>::computeOutputDescriptor()
      38             :     {
      39             :         // output = (input - poolSize) / stride + 1
      40           0 :         IndexVector_t dims(poolingDimensions_ + 1);
      41           0 :         for (int idx = 0; idx < poolingDimensions_; ++idx)
      42           0 :             dims[idx] = (this->inputDescriptors_.front()->getNumberOfCoefficientsPerDimension()[idx]
      43           0 :                          - poolSize_[idx])
      44           0 :                             / strides_
      45           0 :                         + 1;
      46           0 :         dims(poolingDimensions_) = this->inputDescriptors_.front()
      47           0 :                                        ->getNumberOfCoefficientsPerDimension()[poolingDimensions_];
      48           0 :         this->outputDescriptor_ = VolumeDescriptor(dims).clone();
      49           0 :     }
      50             : 
      51             :     template <typename data_t>
      52           0 :     MaxPooling1D<data_t>::MaxPooling1D(index_t poolSize, index_t strides, Padding padding,
      53             :                                        const std::string& name)
      54             :         : Pooling<data_t>(LayerType::MaxPooling1D, 1, IndexVector_t{{poolSize}}, strides, padding,
      55           0 :                           name)
      56             :     {
      57           0 :     }
      58             : 
      59             :     template <typename data_t>
      60           0 :     MaxPooling2D<data_t>::MaxPooling2D(const IndexVector_t& poolSize, index_t strides,
      61             :                                        Padding padding, const std::string& name)
      62           0 :         : Pooling<data_t>(LayerType::MaxPooling2D, 2, {poolSize}, strides, padding, name)
      63             :     {
      64           0 :     }
      65             : 
      66             :     template class Pooling<float>;
      67             :     template struct MaxPooling1D<float>;
      68             :     template struct MaxPooling2D<float>;
      69             : } // namespace elsa::ml

Generated by: LCOV version 1.15