ArmNN
 24.02
MockTensorHandleFactory.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 
6 #pragma once
7 
9 #include <armnnTestUtils/MockMemoryManager.hpp>
10 
11 namespace armnn
12 {
13 
14 constexpr const char* MockTensorHandleFactoryId()
15 {
16  return "Arm/Mock/TensorHandleFactory";
17 }
18 
20 {
21 
22 public:
23  explicit MockTensorHandleFactory(std::shared_ptr<MockMemoryManager> mgr)
24  : m_MemoryManager(mgr)
25  , m_ImportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc))
26  , m_ExportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc))
27  {}
28 
29  std::unique_ptr<ITensorHandle> CreateSubTensorHandle(ITensorHandle& parent,
30  TensorShape const& subTensorShape,
31  unsigned int const* subTensorOrigin) const override;
32 
33  std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo) const override;
34 
35  std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
36  DataLayout dataLayout) const override;
37 
38  std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
39  const bool IsMemoryManaged) const override;
40 
41  std::unique_ptr<ITensorHandle> CreateTensorHandle(const TensorInfo& tensorInfo,
42  DataLayout dataLayout,
43  const bool IsMemoryManaged) const override;
44 
45  static const FactoryId& GetIdStatic();
46 
47  const FactoryId& GetId() const override;
48 
49  bool SupportsSubTensors() const override;
50 
51  MemorySourceFlags GetExportFlags() const override;
52 
53  MemorySourceFlags GetImportFlags() const override;
54 
55 private:
56  mutable std::shared_ptr<MockMemoryManager> m_MemoryManager;
57  MemorySourceFlags m_ImportFlags;
58  MemorySourceFlags m_ExportFlags;
59 };
60 
61 } // namespace armnn
armnn::MemorySource::Malloc
@ Malloc
armnn::MockTensorHandleFactory::CreateSubTensorHandle
std::unique_ptr< ITensorHandle > CreateSubTensorHandle(ITensorHandle &parent, TensorShape const &subTensorShape, unsigned int const *subTensorOrigin) const override
Definition: MockTensorHandleFactory.cpp:20
armnn::DataLayout
DataLayout
Definition: Types.hpp:62
armnn::TensorInfo
Definition: Tensor.hpp:152
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
ITensorHandleFactory.hpp
armnn::ITensorHandle
Definition: ITensorHandle.hpp:16
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::FactoryId
ITensorHandleFactory::FactoryId FactoryId
Definition: MockTensorHandleFactory.cpp:12
armnn::MockTensorHandleFactory
Definition: MockTensorHandleFactory.hpp:19
armnn::ITensorHandleFactory
Definition: ITensorHandleFactory.hpp:46
armnn::MockTensorHandleFactory::MockTensorHandleFactory
MockTensorHandleFactory(std::shared_ptr< MockMemoryManager > mgr)
Definition: MockTensorHandleFactory.hpp:23
armnn::MockTensorHandleFactory::GetId
const FactoryId & GetId() const override
Definition: MockTensorHandleFactory.cpp:67
armnn::MockTensorHandleFactory::GetExportFlags
MemorySourceFlags GetExportFlags() const override
Definition: MockTensorHandleFactory.cpp:77
armnn::MockTensorHandleFactoryId
constexpr const char * MockTensorHandleFactoryId()
Definition: MockTensorHandleFactory.hpp:14
armnn::MemorySource
MemorySource
Define the Memory Source to reduce copies.
Definition: Types.hpp:244
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::MockTensorHandleFactory::SupportsSubTensors
bool SupportsSubTensors() const override
Definition: MockTensorHandleFactory.cpp:72
armnn::MockTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: MockTensorHandleFactory.cpp:14
armnn::MockTensorHandleFactory::GetImportFlags
MemorySourceFlags GetImportFlags() const override
Definition: MockTensorHandleFactory.cpp:82
armnn::MockTensorHandleFactory::CreateTensorHandle
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override
Definition: MockTensorHandleFactory.cpp:27