std::string m_Message;
};
-class ClRuntimeUnavailableException : public Exception
+/// Class for non-fatal exceptions raised while initialising a backend
+class BackendUnavailableException : public Exception
{
public:
using Exception::Exception;
};
+class ClRuntimeUnavailableException : public BackendUnavailableException
+{
+public:
+ using BackendUnavailableException::BackendUnavailableException;
+};
+
class InvalidArgumentException : public Exception
{
public:
virtual IWorkloadFactoryPtr CreateWorkloadFactory(
class TensorHandleFactoryRegistry& tensorHandleFactoryRegistry) const;
+ /// Create the runtime context of the backend
+ ///
+ /// Implementations may return a default-constructed IBackendContextPtr if
+ /// no context is needed at runtime.
+ /// Implementations must throw BackendUnavailableException if the backend
+ /// cannot be used (for example, necessary accelerator hardware is not present).
+ /// The default implementation always returns a default-constructed pointer.
virtual IBackendContextPtr CreateBackendContext(const IRuntime::CreationOptions&) const;
- // Context specifically used for profiling interaction from backends.
+ /// Create context specifically used for profiling interaction from backends.
virtual IBackendProfilingContextPtr CreateBackendProfilingContext(const IRuntime::CreationOptions& creationOptions,
armnn::profiling::IBackendProfiling& backendProfiling) const;
class DeviceSpec : public IDeviceSpec
{
public:
+ DeviceSpec()
+ {}
+
DeviceSpec(const BackendIdSet& supportedBackends)
: m_SupportedBackends{supportedBackends} {}
}
private:
- DeviceSpec() = delete;
BackendIdSet m_SupportedBackends;
BackendIdSet m_DynamicBackends;
};
Runtime::Runtime(const CreationOptions& options)
: m_NetworkIdCounter(0)
- , m_DeviceSpec{BackendRegistryInstance().GetBackendIds()}
{
ARMNN_LOG(info) << "ArmNN v" << ARMNN_VERSION << "\n";
// goes through the backend registry
LoadDynamicBackends(options.m_DynamicBackendsPath);
+ BackendIdSet supportedBackends;
for (const auto& id : BackendRegistryInstance().GetBackendIds())
{
// Store backend contexts for the supported ones
- const BackendIdSet& supportedBackends = m_DeviceSpec.GetSupportedBackends();
- if (supportedBackends.find(id) != supportedBackends.end())
- {
+ try {
auto factoryFun = BackendRegistryInstance().GetFactory(id);
auto backend = factoryFun();
BOOST_ASSERT(backend.get() != nullptr);
{
m_BackendContexts.emplace(std::make_pair(id, std::move(context)));
}
+ supportedBackends.emplace(id);
+ }
+ catch (const BackendUnavailableException&)
+ {
+ // Ignore backends which are unavailable
}
+
}
+ m_DeviceSpec.AddSupportedBackends(supportedBackends);
}
Runtime::~Runtime()
virtual void RegisterDebugCallback(NetworkId networkId, const DebugCallbackFunction& func) override;
/// Creates a runtime for workload execution.
- /// May throw a ClRuntimeUnavailableException if @a defaultComputeDevice requires a CL runtime but
- /// it cannot be setup for some reason.
Runtime(const CreationOptions& options);
~Runtime();