Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / engines / gna / gna_input_precision_test.cpp
1 //
2 // Copyright 2016-2018 Intel Corporation.
3 //
4 // This software and the related documents are Intel copyrighted materials,
5 // and your use of them is governed by the express license under which they
6 // were provided to you (End User License Agreement for the Intel(R) Software
7 // Development Products (Version May 2017)). Unless the License provides
8 // otherwise, you may not use, modify, copy, publish, distribute, disclose or
9 // transmit this software or the related documents without Intel's prior
10 // written permission.
11 //
12 // This software and the related documents are provided as is, with no
13 // express or implied warranties, other than those that are expressly
14 // stated in the License.
15 //
16
17 #include <gtest/gtest.h>
18 #include <gmock/gmock-generated-actions.h>
19 #include "gna_matcher.hpp"
20 #include "matchers/input_data_matcher.hpp"
21 #include "test_irs.hpp"
22
23 using namespace std;
24 using namespace InferenceEngine;
25 using namespace ::testing;
26 using namespace GNATestIRs;
27
28 class GNAInputPrecisionTest : public GNATest {
29 };
30
31 TEST_F(GNAInputPrecisionTest, CanProcessU8Input) {
32     std::vector<float> input_init = {128, 128, 128, 128, 128, 128, 128, 128, 128, 128};
33     double scale = 1.f / 128;
34     std::vector<int16_t> input_processed = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
35
36     assert_that().onInferModel(Fc2DOutputModel())
37             .inNotCompactMode().gna().propagate_forward().called_with()
38             .preprocessed_input_data(input_init, input_processed, Precision::U8)
39             .withGNAConfig(GNA_CONFIG_KEY(SCALE_FACTOR), scale);
40 }
41
42 TEST_F(GNAInputPrecisionTest, CanProcessFP32Input) {
43     std::vector<float> input_init = {1280, 1280, 1280, 1280, 1280, 1280, 1280, 1280, 1280, 1280};
44     double scale = 1.f / 1280;
45     std::vector<int16_t> input_processed = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
46
47     assert_that().onInferModel(Fc2DOutputModel())
48             .inNotCompactMode().gna().propagate_forward().called_with()
49             .preprocessed_input_data(input_init, input_processed, Precision::FP32)
50             .withGNAConfig(GNA_CONFIG_KEY(SCALE_FACTOR), scale);
51 }