ArmNN
 23.08
SampleDynamicWorkloadFactory.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
8 
9 #include <armnn/Optional.hpp>
11 
12 namespace sdb // sample dynamic backend
13 {
14 
15 // Sample Dynamic workload factory.
17 {
18 public:
19  explicit SampleDynamicWorkloadFactory(const std::shared_ptr<SampleMemoryManager>& memoryManager);
21 
23 
24  const armnn::BackendId& GetBackendId() const override;
25 
26  static bool IsLayerSupported(const armnn::IConnectableLayer& layer,
28  std::string& outReasonIfUnsupported);
29 
30  bool SupportsSubTensors() const override { return false; }
31 
32  ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateSubTensorHandle instead")
33  std::unique_ptr<armnn::ITensorHandle> CreateSubTensorHandle(
34  armnn::ITensorHandle& parent,
35  armnn::TensorShape const& subTensorShape,
36  unsigned int const* subTensorOrigin) const override
37  {
38  IgnoreUnused(parent, subTensorShape, subTensorOrigin);
39  return nullptr;
40  }
41 
42  ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
43  std::unique_ptr<armnn::ITensorHandle> CreateTensorHandle(
44  const armnn::TensorInfo& tensorInfo,
45  const bool IsMemoryManaged = true) const override;
46 
47  ARMNN_DEPRECATED_MSG("Use ITensorHandleFactory::CreateTensorHandle instead")
48  std::unique_ptr<armnn::ITensorHandle> CreateTensorHandle(
49  const armnn::TensorInfo& tensorInfo,
50  armnn::DataLayout dataLayout,
51  const bool IsMemoryManaged = true) const override;
52 
53  std::unique_ptr<armnn::IWorkload> CreateAddition(
54  const armnn::AdditionQueueDescriptor& descriptor,
55  const armnn::WorkloadInfo& info) const;
56 
57 
58  std::unique_ptr<armnn::IWorkload> CreateInput(const armnn::InputQueueDescriptor& descriptor,
59  const armnn::WorkloadInfo& info) const;
60 
61  std::unique_ptr<armnn::IWorkload> CreateOutput(const armnn::OutputQueueDescriptor& descriptor,
62  const armnn::WorkloadInfo& info) const;
63 
64  std::unique_ptr<armnn::IWorkload> CreateWorkload(armnn::LayerType type,
65  const armnn::QueueDescriptor& descriptor,
66  const armnn::WorkloadInfo& info) const override;
67 
68 private:
69  mutable std::shared_ptr<SampleMemoryManager> m_MemoryManager;
70 
71 };
72 
73 } // namespace sdb
sdb::SampleDynamicWorkloadFactory::GetBackendId
const armnn::BackendId & GetBackendId() const override
Definition: SampleDynamicWorkloadFactory.cpp:33
armnn::Optional
Definition: Optional.hpp:270
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
sdb::SampleMemoryManager
Definition: SampleMemoryManager.hpp:16
sdb::SampleDynamicWorkloadFactory
Definition: SampleDynamicWorkloadFactory.hpp:16
SampleMemoryManager.hpp
sdb::SampleDynamicWorkloadFactory::CreateTensorHandle
std::unique_ptr< armnn::ITensorHandle > CreateTensorHandle(const armnn::TensorInfo &tensorInfo, const bool IsMemoryManaged=true) const override
Definition: SampleDynamicWorkloadFactory.cpp:45
WorkloadFactory.hpp
sdb
Definition: SampleDynamicAdditionWorkload.cpp:11
sdb::SampleDynamicWorkloadFactory::CreateWorkload
std::unique_ptr< armnn::IWorkload > CreateWorkload(armnn::LayerType type, const armnn::QueueDescriptor &descriptor, const armnn::WorkloadInfo &info) const override
Backends should implement their own CreateWorkload function with a switch statement.
Definition: SampleDynamicWorkloadFactory.cpp:81
sdb::SampleDynamicWorkloadFactory::~SampleDynamicWorkloadFactory
~SampleDynamicWorkloadFactory()
Definition: SampleDynamicWorkloadFactory.hpp:22
Optional.hpp
armnn::OutputQueueDescriptor
MemCopyQueueDescriptor OutputQueueDescriptor
Definition: WorkloadData.hpp:92
sdb::SampleDynamicWorkloadFactory::SupportsSubTensors
bool SupportsSubTensors() const override
Definition: SampleDynamicWorkloadFactory.hpp:30
sdb::SampleDynamicWorkloadFactory::CreateOutput
std::unique_ptr< armnn::IWorkload > CreateOutput(const armnn::OutputQueueDescriptor &descriptor, const armnn::WorkloadInfo &info) const
Definition: SampleDynamicWorkloadFactory.cpp:74
armnn::IWorkloadFactory
Definition: WorkloadFactory.hpp:22
armnn::InputQueueDescriptor
MemCopyQueueDescriptor InputQueueDescriptor
Definition: WorkloadData.hpp:91
ARMNN_DEPRECATED_MSG
#define ARMNN_DEPRECATED_MSG(message)
Definition: Deprecated.hpp:43
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
sdb::SampleDynamicWorkloadFactory::IsLayerSupported
static bool IsLayerSupported(const armnn::IConnectableLayer &layer, armnn::Optional< armnn::DataType > dataType, std::string &outReasonIfUnsupported)
Definition: SampleDynamicWorkloadFactory.cpp:38
sdb::SampleDynamicWorkloadFactory::CreateInput
std::unique_ptr< armnn::IWorkload > CreateInput(const armnn::InputQueueDescriptor &descriptor, const armnn::WorkloadInfo &info) const
Definition: SampleDynamicWorkloadFactory.cpp:67
armnn::IConnectableLayer
Interface for a layer that is connectable to other layers via InputSlots and OutputSlots.
Definition: INetwork.hpp:80
sdb::SampleDynamicWorkloadFactory::SampleDynamicWorkloadFactory
SampleDynamicWorkloadFactory()
Definition: SampleDynamicWorkloadFactory.cpp:28
sdb::SampleDynamicWorkloadFactory::CreateSubTensorHandle
std::unique_ptr< armnn::ITensorHandle > CreateSubTensorHandle(armnn::ITensorHandle &parent, armnn::TensorShape const &subTensorShape, unsigned int const *subTensorOrigin) const override
Definition: SampleDynamicWorkloadFactory.hpp:33
armnn::LayerType
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
Definition: Types.hpp:483
sdb::SampleDynamicWorkloadFactory::CreateAddition
std::unique_ptr< armnn::IWorkload > CreateAddition(const armnn::AdditionQueueDescriptor &descriptor, const armnn::WorkloadInfo &info) const
Definition: SampleDynamicWorkloadFactory.cpp:60