Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / engines / gna / gna_hardware_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 <vector>
18
19 #include <gtest/gtest.h>
20 #include <mock_icnn_network.hpp>
21 #include <cpp/ie_cnn_net_reader.h>
22 #include <gmock/gmock-generated-actions.h>
23 #include "gna_matcher.hpp"
24
25 using namespace std;
26 using namespace InferenceEngine;
27 using namespace ::testing;
28
29 class GNAHWPrecisionTest : public GNATest {
30
31 };
32
33 TEST_F(GNAHWPrecisionTest, defaultPrecisionIsInt16) {
34     assert_that().onInfer1AFModel().gna().propagate_forward().called_with().
35         nnet_input_precision(Precision::I16).
36         nnet_ouput_precision(Precision::I32).
37         nnet_weights_precision(Precision::I16).
38         nnet_biases_precision(Precision::I32);
39 }
40
41 TEST_F(GNAHWPrecisionTest, canPassInt8Precision) {
42     assert_that().onInfer1AFModel().withConfig(PRECISION, Precision::I8).
43         gna().propagate_forward().called_with().
44             nnet_input_precision(Precision::I16).
45             nnet_ouput_precision(Precision::I32).
46             nnet_weights_precision(Precision::I8).
47             nnet_biases_precision(Precision::fromType<intel_compound_bias_t>());
48 }
49
50 TEST_F(GNAHWPrecisionTest, canPassInt16Precision) {
51     assert_that().onInfer1AFModel().withConfig(PRECISION, Precision::I16).
52         gna().propagate_forward().called_with().
53         nnet_input_precision(Precision::I16).
54         nnet_ouput_precision(Precision::I32).
55         nnet_weights_precision(Precision::I16).
56         nnet_biases_precision(Precision::I32);
57 }
58
59 TEST_F(GNAHWPrecisionTest, failToCreatePluginWithUnsuportedPrecision) {
60     assert_that().creating().gna_plugin().withConfig(PRECISION, Precision::FP32).throws();
61 }