ArmNN
 24.08
MockTensorHandleFactory.cpp
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 
7 #include <armnnTestUtils/MockTensorHandle.hpp>
8 
9 namespace armnn
10 {
11 
13 
15 {
16  static const FactoryId s_Id(MockTensorHandleFactoryId());
17  return s_Id;
18 }
19 
21  TensorShape const&,
22  unsigned int const*) const
23 {
24  return nullptr;
25 }
26 
27 std::unique_ptr<ITensorHandle> MockTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo) const
28 {
29  return std::make_unique<MockTensorHandle>(tensorInfo, m_MemoryManager);
30 }
31 
32 std::unique_ptr<ITensorHandle> MockTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo,
33  DataLayout dataLayout) const
34 {
35  IgnoreUnused(dataLayout);
36  return std::make_unique<MockTensorHandle>(tensorInfo, m_MemoryManager);
37 }
38 
39 std::unique_ptr<ITensorHandle> MockTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo,
40  const bool IsMemoryManaged) const
41 {
42  if (IsMemoryManaged)
43  {
44  return std::make_unique<MockTensorHandle>(tensorInfo, m_MemoryManager);
45  }
46  else
47  {
48  return std::make_unique<MockTensorHandle>(tensorInfo, m_ImportFlags);
49  }
50 }
51 
52 std::unique_ptr<ITensorHandle> MockTensorHandleFactory::CreateTensorHandle(const TensorInfo& tensorInfo,
53  DataLayout dataLayout,
54  const bool IsMemoryManaged) const
55 {
56  IgnoreUnused(dataLayout);
57  if (IsMemoryManaged)
58  {
59  return std::make_unique<MockTensorHandle>(tensorInfo, m_MemoryManager);
60  }
61  else
62  {
63  return std::make_unique<MockTensorHandle>(tensorInfo, m_ImportFlags);
64  }
65 }
66 
68 {
69  return GetIdStatic();
70 }
71 
73 {
74  return false;
75 }
76 
78 {
79  return m_ExportFlags;
80 }
81 
83 {
84  return m_ImportFlags;
85 }
86 
87 } // namespace armnn
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
armnn::ITensorHandle
Definition: ITensorHandle.hpp:16
MockTensorHandleFactory.hpp
armnn::TensorShape
Definition: Tensor.hpp:20
armnn::FactoryId
ITensorHandleFactory::FactoryId FactoryId
Definition: MockTensorHandleFactory.cpp:12
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::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49
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