trevdatastreams's picture
Publish Arm NN FlexBuffer OOB reproduction evidence
7bf117f verified
Raw
History Blame Contribute Delete
1.05 kB
#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;
}
}