ArmNN
 24.02
SampleDynamicTensorHandleFactory.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
9 
11 
12 namespace sdb // sample dynamic backend
13 {
14 
15 constexpr const char * SampleDynamicTensorHandleFactoryId() { return "Arm/SampleDynamic/TensorHandleFactory"; }
16 
18 {
19 
20 public:
21  SampleDynamicTensorHandleFactory(std::shared_ptr<SampleMemoryManager> mgr)
22  : m_MemoryManager(mgr),
23  m_ImportFlags(static_cast<armnn::MemorySourceFlags>(armnn::MemorySource::Malloc)),
24  m_ExportFlags(static_cast<armnn::MemorySourceFlags>(armnn::MemorySource::Malloc))
25  {}
26 
27  std::unique_ptr<armnn::ITensorHandle> CreateSubTensorHandle(armnn::ITensorHandle& parent,
28  armnn::TensorShape const& subTensorShape,
29  unsigned int const* subTensorOrigin) const override;
30 
31  std::unique_ptr<armnn::ITensorHandle> CreateTensorHandle(const armnn::TensorInfo& tensorInfo) const override;
32 
33  std::unique_ptr<armnn::ITensorHandle> CreateTensorHandle(const armnn::TensorInfo& tensorInfo,
34  armnn::DataLayout dataLayout) const override;
35 
36  std::unique_ptr<armnn::ITensorHandle> CreateTensorHandle(const armnn::TensorInfo& tensorInfo,
37  const bool IsMemoryManaged) const override;
38 
39  std::unique_ptr<armnn::ITensorHandle> CreateTensorHandle(const armnn::TensorInfo& tensorInfo,
40  armnn::DataLayout dataLayout,
41  const bool IsMemoryManaged) const override;
42 
43  static const FactoryId& GetIdStatic();
44 
45  const FactoryId& GetId() const override;
46 
47  bool SupportsSubTensors() const override;
48 
50 
52 
53 private:
54  mutable std::shared_ptr<SampleMemoryManager> m_MemoryManager;
55  armnn::MemorySourceFlags m_ImportFlags;
56  armnn::MemorySourceFlags m_ExportFlags;
57 };
58 
59 } // namespace sdb
60 
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
sdb::SampleDynamicTensorHandleFactory::CreateSubTensorHandle
std::unique_ptr< armnn::ITensorHandle > CreateSubTensorHandle(armnn::ITensorHandle &parent, armnn::TensorShape const &subTensorShape, unsigned int const *subTensorOrigin) const override
Definition: SampleDynamicTensorHandleFactory.cpp:23
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
ITensorHandleFactory.hpp
SampleMemoryManager.hpp
armnn::ITensorHandle
Definition: ITensorHandle.hpp:16
sdb
Definition: SampleDynamicAdditionWorkload.cpp:11
armnn::TensorShape
Definition: Tensor.hpp:20
sdb::SampleDynamicTensorHandleFactoryId
constexpr const char * SampleDynamicTensorHandleFactoryId()
Definition: SampleDynamicTensorHandleFactory.hpp:15
sdb::SampleDynamicTensorHandleFactory::SampleDynamicTensorHandleFactory
SampleDynamicTensorHandleFactory(std::shared_ptr< SampleMemoryManager > mgr)
Definition: SampleDynamicTensorHandleFactory.hpp:21
armnn::ITensorHandleFactory
Definition: ITensorHandleFactory.hpp:46
sdb::SampleDynamicTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: SampleDynamicTensorHandleFactory.cpp:16
sdb::SampleDynamicTensorHandleFactory
Definition: SampleDynamicTensorHandleFactory.hpp:17
armnn::MemorySource
MemorySource
Define the Memory Source to reduce copies.
Definition: Types.hpp:244
sdb::SampleDynamicTensorHandleFactory::SupportsSubTensors
bool SupportsSubTensors() const override
Definition: SampleDynamicTensorHandleFactory.cpp:80
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
sdb::FactoryId
armnn::ITensorHandleFactory::FactoryId FactoryId
Definition: SampleDynamicTensorHandleFactory.cpp:14
sdb::SampleDynamicTensorHandleFactory::GetId
const FactoryId & GetId() const override
Definition: SampleDynamicTensorHandleFactory.cpp:75
sdb::SampleDynamicTensorHandleFactory::GetImportFlags
armnn::MemorySourceFlags GetImportFlags() const override
Definition: SampleDynamicTensorHandleFactory.cpp:90
sdb::SampleDynamicTensorHandleFactory::CreateTensorHandle
std::unique_ptr< armnn::ITensorHandle > CreateTensorHandle(const armnn::TensorInfo &tensorInfo) const override
Definition: SampleDynamicTensorHandleFactory.cpp:31
sdb::SampleDynamicTensorHandleFactory::GetExportFlags
armnn::MemorySourceFlags GetExportFlags() const override
Definition: SampleDynamicTensorHandleFactory.cpp:85