| #include <armnnDeserializer/IDeserializer.hpp> |
| #include <armnn/IRuntime.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.armnn\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 deserializer = armnnDeserializer::IDeserializer::Create(); |
| auto network = deserializer->CreateNetworkFromBinary(bytes); |
| auto runtime = armnn::IRuntime::Create(armnn::IRuntime::CreationOptions()); |
| auto optimized = armnn::Optimize(*network, {armnn::Compute::CpuRef}, runtime->GetDeviceSpec()); |
| if (!optimized) |
| { |
| std::cerr << "optimization failed\n"; |
| return 1; |
| } |
| std::cout << "loaded and optimized " << bytes.size() << " bytes\n"; |
| return 0; |
| } |
| catch (const std::exception& error) |
| { |
| std::cerr << "load failed: " << error.what() << "\n"; |
| return 1; |
| } |
| } |
|
|