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