{
if (backendPreferences.empty())
{
- throw armnn::InvalidArgumentException("Invoked Optimize with no backends specified");
+ throw InvalidArgumentException("Invoked Optimize with no backends specified");
}
if (options.m_ReduceFp32ToFp16 && options.m_ReduceFp32ToBf16)
failureMsg << "None of the preferred backends " << backendPreferences
<< " are supported. Current platform provides " << backendSettings.m_SupportedBackends;
ReportError(failureMsg.str(), messages);
- return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
+ throw InvalidArgumentException(failureMsg.str());
}
// Create a map to temporarily hold initialized backend objects
if (assignBackendsResult.m_Error)
{
// Failed to assign a backend to each layer
- return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
+ throw InvalidArgumentException("Failed to assign a backend to each layer");
}
Optimizer::Pass(optGraph, MakeOptimizations(OptimizeInverseConversionsFp16(),
if (backendOptimizationResult.m_Error)
{
// Failed to apply the backend-specific optimizations
- return IOptimizedNetworkPtr(nullptr, &IOptimizedNetwork::Destroy);
+ throw InvalidArgumentException("Failed to apply the backend-specific optimizations");
}
// If the debug flag is set, then insert a DebugLayer after each layer
// optimize the network
std::vector<BackendId> backends = {Compute::CpuAcc};
- IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
- BOOST_CHECK(!optNet);
+ std::vector<std::string> errMessages;
+
+ try
+ {
+ Optimize(*net, backends, runtime->GetDeviceSpec(), OptimizerOptions(), errMessages);
+ BOOST_FAIL("Should have thrown an exception.");
+ }
+ catch (const InvalidArgumentException& e)
+ {
+ // Different exceptions are thrown on different backends
+ }
+ BOOST_CHECK(errMessages.size() > 0);
}
BOOST_AUTO_TEST_SUITE_END()
// optimize the network
std::vector<BackendId> backends = {Compute::CpuRef};
- IOptimizedNetworkPtr optNet = Optimize(*net, backends, runtime->GetDeviceSpec());
- BOOST_CHECK(!optNet); // Should have failed to optimise, as flow control is not yet implemented
+ std::vector<std::string> errMessages;
+
+ try
+ {
+ Optimize(*net, backends, runtime->GetDeviceSpec(), OptimizerOptions(), errMessages);
+ BOOST_FAIL("Should have thrown an exception.");
+ }
+ catch (const InvalidArgumentException& e)
+ {
+ // Different exceptions are thrown on different backends
+ }
+ BOOST_TEST(errMessages.size() > 1);
}
BOOST_AUTO_TEST_SUITE_END()
std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
std::vector<std::string> errMessages;
- armnn::IOptimizedNetworkPtr optNet = Optimize(*net,
+
+ try
+ {
+ armnn::IOptimizedNetworkPtr optNet = Optimize(*net,
backends,
runtime->GetDeviceSpec(),
OptimizerOptions(),
errMessages);
-
- BOOST_TEST(errMessages.size() == 1);
- BOOST_TEST(errMessages[0] ==
- "ERROR: output 0 of layer Softmax (softmax) is of type "
- "Quantized 8 bit but its scale parameter has not been set");
- BOOST_TEST(!optNet);
+ BOOST_FAIL("An exception should have been thrown");
+ }
+ catch (const InvalidArgumentException& e)
+ {
+ // Different exceptions are thrown on different backends
+ }
+ BOOST_CHECK(errMessages.size() > 0);
}
BOOST_AUTO_TEST_CASE(RuntimeBackendOptions)
armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
- armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec());
- BOOST_CHECK(!optNet);
+ std::vector<std::string> errMessages;
+
+ try
+ {
+ Optimize(*net, backends, runtime->GetDeviceSpec(), armnn::OptimizerOptions(), errMessages);
+ BOOST_FAIL("Should have thrown an exception.");
+ }
+ catch (const armnn::InvalidArgumentException& e)
+ {
+ // Different exceptions are thrown on different backends
+ }
+ BOOST_CHECK(errMessages.size() > 0);
}
BOOST_AUTO_TEST_CASE(OptimizeValidateDeviceNonSupportLayerWithFallback)
armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
std::vector<armnn::BackendId> backends = { armnn::Compute::Undefined };
+ std::vector<std::string> errMessages;
- armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(net, backends, runtime->GetDeviceSpec());
- BOOST_CHECK(!optNet);
-
+ try
+ {
+ Optimize(net, backends, runtime->GetDeviceSpec(), armnn::OptimizerOptions(), errMessages);
+ BOOST_FAIL("Should have thrown an exception.");
+ }
+ catch (const armnn::InvalidArgumentException& e)
+ {
+ // Different exceptions are thrown on different backends
+ }
+ BOOST_CHECK(errMessages.size() > 0);
}
BOOST_AUTO_TEST_CASE(OptimizeValidateWorkloadsUndefinedComputeDeviceWithFallback)
armnn::IRuntimePtr runtime(armnn::IRuntime::Create(options));
std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
- armnn::IOptimizedNetworkPtr optNet = armnn::Optimize(*net, backends, runtime->GetDeviceSpec());
- BOOST_CHECK(!optNet);
+ std::vector<std::string> errMessages;
+
+ try
+ {
+ Optimize(*net, backends, runtime->GetDeviceSpec(), armnn::OptimizerOptions(), errMessages);
+ BOOST_FAIL("Should have thrown an exception.");
+ }
+ catch (const armnn::InvalidArgumentException& e)
+ {
+ // Different exceptions are thrown on different backends
+ }
+ BOOST_CHECK(errMessages.size() > 0);
}
BOOST_AUTO_TEST_CASE(FastMathEnabledTestOnCpuAcc)