ArmNN
 25.11
Loading...
Searching...
No Matches
WorkloadFactory.hpp
Go to the documentation of this file.
1//
2// Copyright © 2021-2023 Arm Ltd and Contributors. All rights reserved.
3// SPDX-License-Identifier: MIT
4//
5#pragma once
6
7#include "ITensorHandle.hpp"
8#include "Workload.hpp"
9
10#include <armnn/Optional.hpp>
11#include <armnn/INetwork.hpp>
12#include <armnn/TensorFwd.hpp>
13
14#include <memory>
15
16namespace armnn
17{
18
19class Layer;
20
21// Workload factory interface for compute backends.
23{
24public:
25 virtual ~IWorkloadFactory() { }
26
27 virtual void AfterWorkloadsCreated() {};
28
29 virtual const BackendId& GetBackendId() const = 0;
30
31 static bool IsLayerSupported(const BackendId& backendId,
32 const IConnectableLayer& layer,
33 Optional<DataType> dataType,
34 std::string& outReasonIfUnsupported);
35
36 static bool IsLayerSupported(const IConnectableLayer& layer,
37 Optional<DataType> dataType,
38 std::string& outReasonIfUnsupported);
39
40 static bool IsLayerSupported(const IConnectableLayer& layer,
41 Optional<DataType> dataType,
42 std::string& outReasonIfUnsupported,
43 const ModelOptions& modelOptions);
44
45 static bool IsLayerSupported(const BackendId& backendId,
46 const IConnectableLayer& layer,
47 Optional<DataType> dataType,
48 std::string& outReasonIfUnsupported,
49 const ModelOptions& modelOptions);
50
51 virtual bool SupportsSubTensors() const = 0;
52
53 ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateSubTensorHandle instead")
55 TensorShape const& subTensorShape,
56 unsigned int const* subTensorOrigin
57 ) const = 0;
58
59 ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
60 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
61 const bool IsMemoryManaged = true) const = 0;
62
63 ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
64 virtual std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
65 DataLayout dataLayout,
66 const bool IsMemoryManaged = true) const = 0;
67
68 /// Backends should implement their own CreateWorkload function with a switch statement.
69 /// The case for the switch should be the LayerType and based on that they will call their
70 /// specific workload creation functionality.
71 virtual std::unique_ptr<IWorkload> CreateWorkload(LayerType type,
72 const QueueDescriptor& descriptor,
73 const WorkloadInfo& info) const = 0;
74
75private:
76 static bool IsLayerConfigurationSupported(const BackendId& backendId,
77 const IConnectableLayer& connectableLayer,
78 Optional<DataType> dataType,
79 std::string& outReasonIfUnsupported,
80 const ModelOptions& modelOptions = {});
81};
82
83} // namespace armnn
#define ARMNN_DEPRECATED_MSG(message)
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition INetwork.hpp:81
virtual std::unique_ptr< ITensorHandle > CreateSubTensorHandle(ITensorHandle &parent, TensorShape const &subTensorShape, unsigned int const *subTensorOrigin) const =0
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const =0
Backends should implement their own CreateWorkload function with a switch statement.
virtual bool SupportsSubTensors() const =0
virtual void AfterWorkloadsCreated()
static bool IsLayerSupported(const BackendId &backendId, const IConnectableLayer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
virtual const BackendId & GetBackendId() const =0
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo, const bool IsMemoryManaged=true) const =0
Workload interface to enqueue a layer computation.
Definition IWorkload.hpp:14
Copyright (c) 2021 ARM Limited and Contributors.
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition Types.hpp:494
std::vector< BackendOptions > ModelOptions
DataLayout
Definition Types.hpp:63
DataType
Definition Types.hpp:49
Contains information about TensorInfos of a layer.