Publishing 2019 R1.1 content and Myriad plugin sources (#162)
[platform/upstream/dldt.git] / inference-engine / tests / unit / engines / gna / matchers / pool_matcher.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include"gna-api.h"
8 #include "nnet_base_matcher.hpp"
9 #include "quantization/quantization.h"
10
11 class PoolingLayerMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t*> {
12     bool matchInserted;
13     int matchQuantity;
14     bool bMaxPool;
15  public:
16     PoolingLayerMatcher(bool matchInserted, int matchQuantity, bool bMaxPool)
17         : matchInserted(matchInserted), matchQuantity(matchQuantity), bMaxPool(bMaxPool) {}
18     bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
19         if (foo == nullptr)
20             return false;
21         for(int i = 0; i < foo->nLayers; i++) {
22             if (foo->pLayers[i].nLayerKind != INTEL_CONVOLUTIONAL) continue;
23
24             auto conv = (intel_convolutional_layer_t*)foo->pLayers[i].pLayerStruct;
25             if (conv->poolType != INTEL_MAX_POOLING) continue;
26
27             return matchInserted;
28         }
29         return !matchInserted;
30     };
31     void DescribeTo(::std::ostream *os) const override {
32         *os << "should "<< (matchInserted ? "" : "not ") << "have MaxPooling primitive as part of nnet structure";
33     }
34 };
35
36
37