Error std::bad_alloc while creating IRuntime instance
ankitgajera8368 opened this issue · comments
I have successfully compiled the binary 'tensorflow_inference' on board but getting error while executing it. According to the logs, it seems that error is related to creating armnn's iruntime instance:
Suspicious Code:
armnn::IRuntime::CreationOptions options;
armnn::IRuntimePtr runtime = armnn::IRuntime::Create(options);
Code:
for (int testImageIndex = 0; testImageIndex < nTests; testImageIndex++)
{
std::cout << "Reached here .. 1" << std::endl;
auto start = std::chrono::system_clock::now();
std::unique_ptr<MnistImage> input = loadMnistImage(dataDir, testImageIndex);
std::cout << "Reached here .. 2" << std::endl;
if (input == nullptr)
{
return EXIT_FAILURE;
}
/* Import the TensorFlow model */
armnnTfParser::ITfParserPtr
parser = armnnTfParser::ITfParser::Create();
std::cout << "Reached here .. 3" << std::endl;
armnn::INetworkPtr
network = parser->CreateNetworkFromTextFile(TENSOR_MODEL,
{{"Placeholder", {1, 784, 1, 1}}}, {"Softmax"});
std::cout << "Reached here .. 4" << std::endl;
/* Find the binding points for the input and output nodes */
armnnTfParser::BindingPointInfo
inputBindingInfo = parser->GetNetworkInputBindingInfo("Placeholder");
std::cout << "Reached here .. 5" << std::endl;
armnnTfParser::BindingPointInfo
outputBindingInfo = parser->GetNetworkOutputBindingInfo("Softmax");
std::cout << "Reached here .. 6" << std::endl;
armnn::IRuntime::CreationOptions options;
std::cout << "Reached here .. 7" << std::endl;
armnn::IRuntimePtr runtime = armnn::IRuntime::Create(options);
std::cout << "Reached here .. 8" << std::endl;
armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*network,
{armnn::Compute::CpuRef}, runtime->GetDeviceSpec());
std::cout << "Reached here .. 9" << std::endl;
/* Load the optimized network onto the runtime device */
armnn::NetworkId networkIdentifier;
runtime->LoadNetwork(networkIdentifier, std::move(optNet));
std::cout << "Reached here .. 10" << std::endl;
Output Logs :-
Reached here .. 1
Reached here .. 2
Reached here .. 3
Reached here .. 4
Reached here .. 5
Reached here .. 6
Reached here .. 7
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Aborted
It would be a great help if anyone can point out any mistake or I am missing something or not.
Thanks in advance.