From 84da38b0f11ca3db0a439e510514be780f3933ff Mon Sep 17 00:00:00 2001 From: Derek Lamberti Date: Thu, 13 Jun 2019 11:40:08 +0100 Subject: IVGCVSW-3277 Refactor TensorHandle factory API * Added backend support for multiple types of TensorHandle factories * Refactored the backend API to enable new tensor strategies * Added mechanism to determine memory strategies during optimization * Perform mem-copy only when Direct access is not found * Explicitly deleted the copy-constructor from OutputSlot to prevent accidental local copies that would cause the DisconnectAll to be called by the destructor Change-Id: I7e812c8e5e6c1c20db1c5932749ac70fd93db7f8 Signed-off-by: Derek Lamberti Signed-off-by: Matteo Martincigh --- .../backendsCommon/ITensorHandleFactory.hpp | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/backends/backendsCommon/ITensorHandleFactory.hpp (limited to 'src/backends/backendsCommon/ITensorHandleFactory.hpp') diff --git a/src/backends/backendsCommon/ITensorHandleFactory.hpp b/src/backends/backendsCommon/ITensorHandleFactory.hpp new file mode 100644 index 0000000000..7685061eb3 --- /dev/null +++ b/src/backends/backendsCommon/ITensorHandleFactory.hpp @@ -0,0 +1,49 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include +#include + +namespace armnn +{ + +class ITensorHandleFactory +{ +public: + using FactoryId = std::string; + static const FactoryId LegacyFactoryId; // Use the workload factory to create the tensor handle + static const FactoryId DeferredFactoryId; // Some TensorHandleFactory decisions are deferred to run-time + + virtual ~ITensorHandleFactory() {} + + + virtual std::unique_ptr CreateSubTensorHandle(ITensorHandle& parent, + TensorShape const& subTensorShape, + unsigned int const* subTensorOrigin) const = 0; + + virtual std::unique_ptr CreateTensorHandle(const TensorInfo& tensorInfo) const = 0; + + virtual const FactoryId GetId() const = 0; + + virtual bool SupportsSubTensors() const = 0; + + virtual bool SupportsMapUnmap() const final { return true; } + + virtual bool SupportsExport() const final { return false; } + + virtual bool SupportsImport() const final { return false; } +}; + +enum class MemoryStrategy +{ + Undefined, + DirectCompatibility, // Only allocate the tensorhandle using the assigned factory + CopyToTarget, // Default + Insert MemCopy node before target + ExportToTarget, // Default + Insert Import node +}; + +} //namespace armnn -- cgit v1.2.1