aboutsummaryrefslogtreecommitdiff
path: root/src/armnnTfLiteParser/test/TfLiteParser.cpp
blob: 65bbaeae0f0fbffb330e25433fb185f276eb3d77 (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
//
// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "ParserFlatbuffersFixture.hpp"
#include <doctest/doctest.h>

TEST_SUITE("TensorflowLiteParser")
{
TEST_CASE("ParseEmptyBinaryData")
{
    ITfLiteParser::TfLiteParserOptions options;
    ITfLiteParserPtr m_Parser(ITfLiteParser::Create(armnn::Optional<ITfLiteParser::TfLiteParserOptions>(options)));
    // Should throw armnn::ParseException: Buffer doesn't conform to the expected Tensorflow Lite flatbuffers format.
    CHECK_THROWS_AS(m_Parser->CreateNetworkFromBinary({0}), armnn::ParseException);
}

struct NoInputBindingsFixture : public ParserFlatbuffersFixture
{
    explicit NoInputBindingsFixture()
    {
        m_JsonString = R"(
            {
                "version": 3,
                "operator_codes": [ { "builtin_code": "CONV_2D" } ],
                "subgraphs": [ { } ]
            }
        )";
        SetupSingleInputSingleOutput("inputTensor", "outputTensor");
    }
};

TEST_CASE_FIXTURE(NoInputBindingsFixture, "ParseBadInputBindings")
{
    // Should throw armnn::ParseException: No input binding found for subgraph:0 and name:inputTensor.
    CHECK_THROWS_AS((RunTest<4, armnn::DataType::QAsymmU8>(0, { }, { 0 })), armnn::ParseException);
}

}