diff options
author | Matteo Martincigh <matteo.martincigh@arm.com> | 2019-11-28 15:45:42 +0000 |
---|---|---|
committer | Narumol Prangnawarat <narumol.prangnawarat@arm.com> | 2019-12-09 12:00:04 +0000 |
commit | e5b8eb9fe8147a0849db08ef0898a0e8bef920b4 (patch) | |
tree | 54f039796753b6a395eb9f76e46e11a9413dabad /include/armnn/backends/ITensorHandleFactory.hpp | |
parent | 3e2969d7195d77796774101580b837681505904a (diff) | |
download | armnn-e5b8eb9fe8147a0849db08ef0898a0e8bef920b4.tar.gz |
IVGCVSW-4210 Create a public API for the common backend files
* Create a public API for the common backend files
* Move OutputHandler to armnn internal
* Remove unused headers
Signed-off-by: Matteo Martincigh <matteo.martincigh@arm.com>
Signed-off-by: Narumol Prangnawarat <narumol.prangnawarat@arm.com>
Change-Id: I3e86d908b021e3561befa9d45158d87d2cbb18c0
Diffstat (limited to 'include/armnn/backends/ITensorHandleFactory.hpp')
-rw-r--r-- | include/armnn/backends/ITensorHandleFactory.hpp | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/include/armnn/backends/ITensorHandleFactory.hpp b/include/armnn/backends/ITensorHandleFactory.hpp new file mode 100644 index 0000000000..2e4742301b --- /dev/null +++ b/include/armnn/backends/ITensorHandleFactory.hpp @@ -0,0 +1,72 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +#include <armnn/IRuntime.hpp> +#include <armnn/MemorySources.hpp> +#include <armnn/Types.hpp> +#include "ITensorHandle.hpp" + +#include <boost/core/ignore_unused.hpp> + +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<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent, + TensorShape const& subTensorShape, + unsigned int const* subTensorOrigin) const = 0; + + virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const = 0; + + virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, + DataLayout dataLayout) const = 0; + + // Utility Functions for backends which require TensorHandles to have unmanaged memory. + // These should be overloaded if required to facilitate direct import of input tensors + // and direct export of output tensors. + virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, + const bool IsMemoryManaged) const + { + boost::ignore_unused(IsMemoryManaged); + return CreateTensorHandle(tensorInfo); + } + + virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo, + DataLayout dataLayout, + const bool IsMemoryManaged) const + { + boost::ignore_unused(IsMemoryManaged); + return CreateTensorHandle(tensorInfo, dataLayout); + } + + virtual const FactoryId& GetId() const = 0; + + virtual bool SupportsSubTensors() const = 0; + + virtual bool SupportsMapUnmap() const final { return true; } + + virtual MemorySourceFlags GetExportFlags() const { return 0; } + virtual MemorySourceFlags GetImportFlags() const { return 0; } +}; + +enum class EdgeStrategy +{ + Undefined, /// No strategy has been defined. Used internally to verify integrity of optimizations. + DirectCompatibility, /// Destination backend can work directly with tensors on source backend. + ExportToTarget, /// Source backends tensor data can be exported to destination backend tensor without copy. + CopyToTarget /// Copy contents from source backend tensor to destination backend tensor. +}; + +} //namespace armnn |