ArmNN
 24.08
TosaRefWorkloadFactory.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 
9 #include <armnn/Optional.hpp>
12 
13 
14 namespace armnn
15 {
16 
17 // Reference workload factory.
19 {
20 public:
21  explicit TosaRefWorkloadFactory(const std::shared_ptr<TosaRefMemoryManager>& memoryManager);
23 
25 
26  const BackendId& GetBackendId() const override;
27 
28  static bool IsLayerSupported(const Layer& layer,
29  Optional<DataType> dataType,
30  std::string& outReasonIfUnsupported);
31 
32  static bool IsLayerSupported(const IConnectableLayer& layer,
33  Optional<DataType> dataType,
34  std::string& outReasonIfUnsupported,
35  const ModelOptions& modelOptions);
36 
37  bool SupportsSubTensors() const override { return false; }
38 
39  ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateSubTensorHandle instead")
41  TensorShape const& subTensorShape,
42  unsigned int const* subTensorOrigin) const override
43  {
44  IgnoreUnused(parent, subTensorShape, subTensorOrigin);
45  return nullptr;
46  }
47 
48  ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
49  std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
50  const bool IsMemoryManaged = true) const override;
51 
53  std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
54  DataLayout dataLayout,
55  const bool IsMemoryManaged = true) const override;
56 
57  std::unique_ptr<IWorkload> CreateWorkload(LayerType type,
58  const QueueDescriptor& descriptor,
59  const WorkloadInfo& info) const override;
60 
61 private:
62  template <typename F32Workload, typename U8Workload, typename QueueDescriptorType>
63  std::unique_ptr<IWorkload> MakeWorkload(const QueueDescriptorType& descriptor, const WorkloadInfo& info) const;
64 
65  mutable std::shared_ptr<TosaRefMemoryManager> m_MemoryManager;
66 };
67 
68 } // namespace armnn
armnn::TosaRefWorkloadFactory::CreateWorkload
std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const override
Backends should implement their own CreateWorkload function with a switch statement.
Definition: TosaRefWorkloadFactory.cpp:110
armnn::Optional
Definition: Optional.hpp:270
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::TosaRefWorkloadFactory::GetBackendId
const BackendId & GetBackendId() const override
Definition: TosaRefWorkloadFactory.cpp:59
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::IWorkload
Workload interface to enqueue a layer computation.
Definition: IWorkload.hpp:23
armnn::ITensorHandle
Definition: ITensorHandle.hpp:16
IgnoreUnused.hpp
TosaRefMemoryManager.hpp
armnn::TosaRefWorkloadFactory
Definition: TosaRefWorkloadFactory.hpp:18
WorkloadFactory.hpp
armnn::TosaRefWorkloadFactory::CreateTensorHandle
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo, const bool IsMemoryManaged=true) const override
Definition: TosaRefWorkloadFactory.cpp:79
armnn::TosaRefWorkloadFactory::TosaRefWorkloadFactory
TosaRefWorkloadFactory()
Definition: TosaRefWorkloadFactory.cpp:54
armnn::Layer
Definition: Layer.hpp:230
armnn::TensorShape
Definition: Tensor.hpp:20
Optional.hpp
armnn::WorkloadInfo
Contains information about TensorInfos of a layer.
Definition: WorkloadInfo.hpp:16
armnn::TosaRefWorkloadFactory::SupportsSubTensors
bool SupportsSubTensors() const override
Definition: TosaRefWorkloadFactory.hpp:37
armnn::TosaRefWorkloadFactory::CreateSubTensorHandle
std::unique_ptr< ITensorHandle > CreateSubTensorHandle(ITensorHandle &parent, TensorShape const &subTensorShape, unsigned int const *subTensorOrigin) const override
Definition: TosaRefWorkloadFactory.hpp:40
armnn::IWorkloadFactory
Definition: WorkloadFactory.hpp:22
armnn::QueueDescriptor
Definition: WorkloadData.hpp:24
armnn::ITensorHandleFactory
Definition: ITensorHandleFactory.hpp:46
armnn::TosaRefWorkloadFactory::IsLayerSupported
static bool IsLayerSupported(const Layer &layer, Optional< DataType > dataType, std::string &outReasonIfUnsupported)
Definition: TosaRefWorkloadFactory.cpp:64
ARMNN_DEPRECATED_MSG
#define ARMNN_DEPRECATED_MSG(message)
Definition: Deprecated.hpp:43
armnn::TosaRefMemoryManager
Definition: TosaRefMemoryManager.hpp:16
std
Definition: BackendId.hpp:149
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn::BackendId
Definition: BackendId.hpp:75
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::TosaRefWorkloadFactory::~TosaRefWorkloadFactory
~TosaRefWorkloadFactory()
Definition: TosaRefWorkloadFactory.hpp:24
armnn::IConnectableLayer
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:80
armnn::ModelOptions
std::vector< BackendOptions > ModelOptions
Definition: BackendOptions.hpp:18
armnn::LayerType
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:491