Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / tests / unit / shape_infer / built_in_shape_infer_fake_test.cpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #include <gtest/gtest.h>
6 #include <inference_engine/shape_infer/built-in/ie_built_in_holder.hpp>
7 #include <xml_net_builder.hpp>
8 #include <inference_engine/cnn_network_impl.hpp>
9 #include <inference_engine/ie_format_parser.h>
10 #include <xml_helper.hpp>
11 #include <inference_engine/shape_infer/ie_reshaper.hpp>
12 #include "built_in_shape_infer_general_test.hpp"
13
14 using namespace InferenceEngine;
15 using namespace ShapeInfer;
16
17 class BuiltInShapeInferImplFakeTest : public BuiltInShapeInferImplTest {
18 };
19
20 TEST_P(BuiltInShapeInferImplFakeTest, reshaper) {
21     auto cnnNetworkImplPtr = buildSingleLayerNetwork<3>(type, inOutShapes, &layerParams.data, layerDataName);
22     auto reshaper = std::make_shared<Reshaper>(*cnnNetworkImplPtr);
23     auto inputShapes = setInputShapes(*cnnNetworkImplPtr, newInOutShapes.inDims);
24
25     if (canInfer) {
26         reshaper->run(inputShapes);
27         checkNetworkInOut(*cnnNetworkImplPtr, newInOutShapes);
28     } else {
29         ASSERT_THROW(reshaper->run(inputShapes), InferenceEngine::details::InferenceEngineException);
30     }
31 }
32
33 //TODO: use static variables for dimensions and parameters!!
34 //TODO: think about shorter instantiation
35
36 INSTANTIATE_TEST_CASE_P(
37         BuiltInImplsFake2, BuiltInShapeInferImplFakeTest,
38         ::testing::Values(
39                 ::testing::make_tuple(LayerType("NOT_KNOWN"),
40                                       InOutShapes({{{1, 2, 3, 4}, {1, 2}, {1, 2, 3}},
41                                                    {{2, 1},       {2, 1}, {2, 1}}}),
42                                       NewInOutShapes({{{1, 2, 3, 4}, {1, 2}, {1, 2, 3}},
43                                                       {{2, 1},       {2, 1}, {2, 1}}}),
44                                       MapParams(MapStrStr()),
45                                       LayerDataName("data"),
46                                       CanInfer(true)),
47                 ::testing::make_tuple(LayerType("NOT_KNOWN"),
48                                       InOutShapes({{{1, 2, 3, 4}},
49                                                    {{2, 1}}}),
50                                       NewInOutShapes({{{BATCH, 2, 3, 4}},
51                                                       {{BATCH, 1}}}),
52                                       MapParams(MapStrStr()),
53                                       LayerDataName("data"),
54                                       CanInfer(false)),
55                 ::testing::make_tuple(LayerType("NOT_KNOWN"),
56                                       InOutShapes({{{1, 2, 3, 4}, {1, 2}},
57                                                    {{2, 1},       {2, 1}, {2, 1}}}),
58                                       NewInOutShapes({{{1, 2, 3, 4}, {BATCH, 2}},
59                                                       {{2, 1},       {2,     1}, {2, 1}}}),
60                                       MapParams(MapStrStr()),
61                                       LayerDataName("data"),
62                                       CanInfer(false)),
63                 ::testing::make_tuple(LayerType("NOT_KNOWN"),
64                                       InOutShapes({{{1, 2, 3, 4}},
65                                                    {{2, 1}, {2, 1}, {2, 1}}}),
66                                       NewInOutShapes({{{BATCH, 2, 3, 4}},
67                                                       {{BATCH, 1}, {BATCH, 1}, {BATCH, 1}}}),
68                                       MapParams(MapStrStr()),
69                                       LayerDataName("data"),
70                                       CanInfer(false)),
71                 ::testing::make_tuple(LayerType("NOT_KNOWN"),
72                                       InOutShapes({{{1, 2, 3, 4}},
73                                                    {{2, 1}, {2, 1}, {2, 1}}}),
74                                       NewInOutShapes({{{1, BATCH, 3, 4}},
75                                                       {{2, 1}, {2, 1}, {2, 1}}}),
76                                       MapParams(MapStrStr()),
77                                       LayerDataName("data"),
78                                       CanInfer(false)))
79 );