summaryrefslogtreecommitdiff
path: root/inference-engine/tests/unit/cnn_network/v3_format_parser_test.cpp
blob: a8c6e7003b8f3d46026566fb2aaca37a44d63356 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//

#define MT_BATCH 1
#define MT_CHANNELS 3
#define MT_DEPTH 2
#define MT_HEIGHT 1
#define MT_WIDTH 2
#define LAYER_COUNT 1
#include "parser_tests_base.hpp"


#include "parser_tests_base.hpp"

using namespace std;
using namespace InferenceEngine;
using namespace InferenceEngine::details;
using namespace testing;

class V3FormatParserTest : public FormatParserTest {
};

TEST_F(V3FormatParserTest, DISABLED_canNotParseEmptyElementwiseNode) {
    string content = BEGIN_NET_V3()
        .initlayerInOut("e", "Eltwise", 1, 1, 2)
        .node("data").attr("operation", "").close()
        .close()
            END_NET();

    ASSERT_NO_FATAL_FAILURE(assertParseFail(content));
}

TEST_F(V3FormatParserTest, DISABLED_canNotParseMissedElementwiseNodeType) {
    string content = BEGIN_NET_V3()
        .initlayerInOut("e", "Eltwise", 1, 1, 2)
        .close()
            END_NET();

    ASSERT_NO_FATAL_FAILURE(assertParseFail(content));
}

TEST_F(V3FormatParserTest, cannotParseUnknownEltwiseOperation) {
    string content = BEGIN_NET_V3()
        .initlayerInOut("e", "Eltwise", 1, 1, 2)
        .node("data").attr("operation", "unknown").close()
        .close()
            END_NET();

    ASSERT_NO_FATAL_FAILURE(assertParseFail(content));
}

TEST_F(V3FormatParserTest, canParseProdInElementwiseNode) {
    string content = BEGIN_NET_V3()
        .initlayerInOut("e", "Eltwise", 1, 1, 2)
        .node("data").attr("operation", "prod").close()
        .close()
            END_NET();

    ASSERT_NO_FATAL_FAILURE(assertParseSucceed(content));
    CNNLayerPtr ewise;
    ASSERT_EQ(OK, net->getLayerByName("e", ewise, nullptr));
    auto *eltwise = dynamic_cast<EltwiseLayer *>(ewise.get());
    ASSERT_NE(nullptr, eltwise);
    ASSERT_EQ(eltwise->_operation, EltwiseLayer::Prod);
}

TEST_F(V3FormatParserTest, canParseMulInElementwiseNode) {
    string content = BEGIN_NET_V3()
        .initlayerInOut("e", "Eltwise", 1, 1, 2)
        .node("data").attr("operation", "mul").close()
        .close()
            END_NET();

    ASSERT_NO_FATAL_FAILURE(assertParseSucceed(content));
    CNNLayerPtr ewise;
    ASSERT_EQ(OK, net->getLayerByName("e", ewise, nullptr));
    auto *eltwise = dynamic_cast<EltwiseLayer *>(ewise.get());
    ASSERT_NE(nullptr, eltwise);
    ASSERT_EQ(eltwise->_operation, EltwiseLayer::Prod);
}

TEST_F(V3FormatParserTest, canParse5Dinput) {
    string content = xml().node("net").attr("name", "Only_input_5D").attr("version", 3)
            .initInputlayer5D("data", 0, 0);

    ASSERT_NO_FATAL_FAILURE(assertParseFail(content));
}

TEST_F(V3FormatParserTest, DISABLE_conv3DInvalidKernel) {
    string content = xml().node("net").attr("name", "5d_net").attr("version", 3)
            .initConv5DlayerInOut("3D_conv", 0, 1, 64, "", "0,0,0", "0,0,0", "1,1,1", "1,1,1", 0, 0)
            .close();

    ASSERT_NO_FATAL_FAILURE(assertParseFail(content));
}