blob: 9e61b5f1ed40abcccd634f3962f9a21be7171947 [file] [log] [blame]
Derek Lamberti84da38b2019-06-13 11:40:08 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5
6#pragma once
7
Derek Lamberti84da38b2019-06-13 11:40:08 +01008#include <armnn/IRuntime.hpp>
Derek Lambertif674aa02019-08-01 15:56:25 +01009#include <armnn/MemorySources.hpp>
10#include <armnn/Types.hpp>
Derek Lamberti84da38b2019-06-13 11:40:08 +010011
12namespace armnn
13{
14
15class ITensorHandleFactory
16{
17public:
18 using FactoryId = std::string;
19 static const FactoryId LegacyFactoryId; // Use the workload factory to create the tensor handle
20 static const FactoryId DeferredFactoryId; // Some TensorHandleFactory decisions are deferred to run-time
21
22 virtual ~ITensorHandleFactory() {}
23
Derek Lamberti84da38b2019-06-13 11:40:08 +010024 virtual std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
25 TensorShape const& subTensorShape,
26 unsigned int const* subTensorOrigin) const = 0;
27
28 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const = 0;
29
Narumol Prangnawarat4e3e8182019-08-14 12:25:50 +010030 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
31 DataLayout dataLayout) const = 0;
32
Derek Lamberti84da38b2019-06-13 11:40:08 +010033 virtual const FactoryId GetId() const = 0;
34
35 virtual bool SupportsSubTensors() const = 0;
36
37 virtual bool SupportsMapUnmap() const final { return true; }
38
Derek Lambertif674aa02019-08-01 15:56:25 +010039 virtual MemorySourceFlags GetExportFlags() const { return 0; }
40 virtual MemorySourceFlags GetImportFlags() const { return 0; }
Derek Lamberti84da38b2019-06-13 11:40:08 +010041};
42
Derek Lambertif674aa02019-08-01 15:56:25 +010043enum class EdgeStrategy
Derek Lamberti84da38b2019-06-13 11:40:08 +010044{
Derek Lambertif674aa02019-08-01 15:56:25 +010045 Undefined, /// No strategy has been defined. Used internally to verify integrity of optimizations.
46 DirectCompatibility, /// Destination backend can work directly with tensors on source backend.
47 ExportToTarget, /// Source backends tensor data can be exported to destination backend tensor without copy.
48 CopyToTarget /// Copy contents from source backend tensor to destination backend tensor.
Derek Lamberti84da38b2019-06-13 11:40:08 +010049};
50
51} //namespace armnn