From 992d6dc57d8463729910b688f0fb5825d0d3ccf2 Mon Sep 17 00:00:00 2001 From: Matteo Martincigh Date: Thu, 10 Jan 2019 17:34:20 +0000 Subject: IVGCVSW-2454 Refactor ArmNN to support pluggable backends from a separate code base * Made the virtual functions in ILayerSupport.hpp pure * Created a LayerSupportBase class with the default implementation of the interface * Made the backend layer support classes inherit from the base class, instead of directly from the interface * Refactored the profiler and the profiling event classes to use the BackendId instead of the Compute * Implemented a proper MemCopy support method * Changed Compute to BackendId in the profiling API and objects * Removed static references to pluggable backends !android-nn-driver:492 Change-Id: Id6332b5f48c980819e0a09adc818d1effd057296 --- include/armnn/BackendId.hpp | 23 +++--- include/armnn/ILayerSupport.hpp | 90 +++++++++++++----------- include/armnn/LayerSupport.hpp | 152 +++++++++++++++++++++------------------- 3 files changed, 139 insertions(+), 126 deletions(-) (limited to 'include') diff --git a/include/armnn/BackendId.hpp b/include/armnn/BackendId.hpp index 8de985ec2f..87206073be 100644 --- a/include/armnn/BackendId.hpp +++ b/include/armnn/BackendId.hpp @@ -20,13 +20,13 @@ namespace armnn // enum class Compute { + Undefined = 0, /// CPU Execution: Reference C++ kernels - CpuRef = 0, + CpuRef = 1, /// CPU Execution: NEON: ArmCompute - CpuAcc = 1, + CpuAcc = 2, /// GPU Execution: OpenCL: ArmCompute - GpuAcc = 2, - Undefined = 5 + GpuAcc = 3 }; /// Deprecated function that will be removed together with @@ -46,7 +46,8 @@ constexpr char const* GetComputeDeviceAsCString(Compute compute) /// the Compute enum inline std::ostream& operator<<(std::ostream& os, const std::vector& compute) { - for (const Compute& comp : compute) { + for (const Compute& comp : compute) + { os << GetComputeDeviceAsCString(comp) << " "; } return os; @@ -56,7 +57,8 @@ inline std::ostream& operator<<(std::ostream& os, const std::vector& co /// the Compute enum inline std::ostream& operator<<(std::ostream& os, const std::set& compute) { - for (const Compute& comp : compute) { + for (const Compute& comp : compute) + { os << GetComputeDeviceAsCString(comp) << " "; } return os; @@ -70,13 +72,10 @@ inline std::ostream& operator<<(std::ostream& os, const Compute& compute) return os; } -struct UninitializedBackendId {}; - class BackendId final { public: - BackendId() { GetComputeDeviceAsCString(Compute::Undefined); } - BackendId(UninitializedBackendId) { GetComputeDeviceAsCString(Compute::Undefined); } + BackendId() : m_Id(GetComputeDeviceAsCString(Compute::Undefined)) {} BackendId(const std::string& id) : m_Id{id} {} BackendId(const char* id) : m_Id{id} {} @@ -132,7 +131,7 @@ private: std::string m_Id; }; -} +} // namespace armnn namespace std { @@ -163,7 +162,7 @@ inline std::ostream& operator<<(std::ostream& os, const BackendId& id) template