Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / engines / gna / matchers / input_data_matcher.hpp
1 #include <utility>
2
3 /*
4  * INTEL CONFIDENTIAL
5  * Copyright (C) 2018-2019 Intel Corporation.
6  *
7  * The source code contained or described herein and all documents
8  * related to the source code ("Material") are owned by Intel Corporation
9  * or its suppliers or licensors. Title to the Material remains with
10  * Intel Corporation or its suppliers and licensors. The Material may
11  * contain trade secrets and proprietary and confidential information
12  * of Intel Corporation and its suppliers and licensors, and is protected
13  * by worldwide copyright and trade secret laws and treaty provisions.
14  * No part of the Material may be used, copied, reproduced, modified,
15  * published, uploaded, posted, transmitted, distributed, or disclosed
16  * in any way without Intel's prior express written permission.
17  *
18  * No license under any patent, copyright, trade secret or other
19  * intellectual property right is granted to or conferred upon you by
20  * disclosure or delivery of the Materials, either expressly, by implication,
21  * inducement, estoppel or otherwise. Any license under such intellectual
22  * property rights must be express and approved by Intel in writing.
23  *
24  * Include any supplier copyright notices as supplier requires Intel to use.
25  *
26  * Include supplier trademarks or logos as supplier requires Intel to use,
27  * preceded by an asterisk. An asterisked footnote can be added as follows:
28  * *Third Party trademarks are the property of their respective owners.
29  *
30  * Unless otherwise agreed by Intel in writing, you may not remove or alter
31  * this notice or any other notice embedded in Materials by Intel or Intel's
32  * suppliers or licensors in any way.
33  */
34
35 #pragma once
36
37 #include <gmock/gmock-matchers.h>
38 #include "nnet_base_matcher.hpp"
39
40 class InputDataMatcher : public ::testing::MatcherInterface<const intel_nnet_type_t *> {
41     std::vector<int16_t> refInput;
42 public:
43
44     explicit InputDataMatcher(const std::vector<int16_t> &_refInput) : refInput(_refInput) {}
45
46     bool MatchAndExplain(const intel_nnet_type_t *foo, ::testing::MatchResultListener *listener) const override {
47         if (foo->pLayers == nullptr) {
48             *listener << "Address of the first layer descriptor is NULL";
49             return false;
50         }
51         auto firstLayer = foo->pLayers[0];
52         auto actualInput = firstLayer.pInputs;
53         if (!actualInput) {
54             *listener << "Input of the first layer is NULL";
55             return false;
56         }
57
58         auto *actualInputI16 = reinterpret_cast<int16_t *>(actualInput);
59         for (int i = 0; i < refInput.size(); i++) {
60             if (actualInputI16[i] != refInput[i]) {
61                 *listener << "Actual and reference value of input doesn't match: " << actualInputI16[i] << " vs "
62                           << refInput[i];
63             }
64         }
65         return true;
66     }
67
68     void DescribeTo(::std::ostream *os) const override {}
69 };