File size: 1,052 Bytes
7bf117f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#include <armnnTfLiteParser/ITfLiteParser.hpp>

#include <cstdint>
#include <fstream>
#include <iostream>
#include <iterator>
#include <vector>

int main(int argc, char** argv)
{
    if (argc != 2)
    {
        std::cerr << "usage: " << argv[0] << " MODEL.tflite\n";
        return 2;
    }

    std::ifstream input(argv[1], std::ios::binary);
    if (!input)
    {
        std::cerr << "could not open model\n";
        return 2;
    }

    std::vector<uint8_t> bytes(
        (std::istreambuf_iterator<char>(input)),
        std::istreambuf_iterator<char>());

    try
    {
        auto parser = armnnTfLiteParser::ITfLiteParser::Create();
        auto network = parser->CreateNetworkFromBinary(bytes);
        if (!network)
        {
            std::cerr << "parser returned a null network\n";
            return 3;
        }
        std::cout << "loaded " << bytes.size() << " bytes\n";
        return 0;
    }
    catch (const std::exception& error)
    {
        std::cerr << "load failed: " << error.what() << '\n';
        return 1;
    }
}