xref: /aosp_15_r20/external/armnn/src/armnnTfLiteParser/test/TfLiteParser.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "ParserFlatbuffersFixture.hpp"
7 #include <doctest/doctest.h>
8 
9 TEST_SUITE("TensorflowLiteParser")
10 {
11 TEST_CASE("ParseEmptyBinaryData")
12 {
13     ITfLiteParser::TfLiteParserOptions options;
14     ITfLiteParserPtr m_Parser(ITfLiteParser::Create(armnn::Optional<ITfLiteParser::TfLiteParserOptions>(options)));
15     // Should throw armnn::ParseException: Buffer doesn't conform to the expected Tensorflow Lite flatbuffers format.
16     CHECK_THROWS_AS(m_Parser->CreateNetworkFromBinary({0}), armnn::ParseException);
17 }
18 
19 struct NoInputBindingsFixture : public ParserFlatbuffersFixture
20 {
NoInputBindingsFixtureNoInputBindingsFixture21     explicit NoInputBindingsFixture()
22     {
23         m_JsonString = R"(
24             {
25                 "version": 3,
26                 "operator_codes": [ { "builtin_code": "CONV_2D" } ],
27                 "subgraphs": [ { } ]
28             }
29         )";
30         SetupSingleInputSingleOutput("inputTensor", "outputTensor");
31     }
32 };
33 
34 TEST_CASE_FIXTURE(NoInputBindingsFixture, "ParseBadInputBindings")
35 {
36     // Should throw armnn::ParseException: No input binding found for subgraph:0 and name:inputTensor.
37     CHECK_THROWS_AS((RunTest<4, armnn::DataType::QAsymmU8>(0, { }, { 0 })), armnn::ParseException);
38 }
39 
40 }
41