ArmNN
 24.08
ClImportTensorHandleFactory Class Reference

This factory creates ClImportTensorHandles that refer to imported memory tensors. More...

#include <ClImportTensorHandleFactory.hpp>

Inheritance diagram for ClImportTensorHandleFactory:
[legend]
Collaboration diagram for ClImportTensorHandleFactory:
[legend]

Public Member Functions

 ClImportTensorHandleFactory (MemorySourceFlags importFlags, MemorySourceFlags exportFlags)
 Create a tensor handle factory for tensors that will be imported or exported. More...
 
std::unique_ptr< ITensorHandleCreateSubTensorHandle (ITensorHandle &parent, const TensorShape &subTensorShape, const unsigned int *subTensorOrigin) const override
 
std::unique_ptr< ITensorHandleCreateTensorHandle (const TensorInfo &tensorInfo) const override
 
std::unique_ptr< ITensorHandleCreateTensorHandle (const TensorInfo &tensorInfo, DataLayout dataLayout) const override
 
std::unique_ptr< ITensorHandleCreateTensorHandle (const TensorInfo &tensorInfo, const bool IsMemoryManaged) const override
 Utility Functions for backends which require TensorHandles to have unmanaged memory. More...
 
std::unique_ptr< ITensorHandleCreateTensorHandle (const TensorInfo &tensorInfo, DataLayout dataLayout, const bool IsMemoryManaged) const override
 
const FactoryIdGetId () const override
 
bool SupportsSubTensors () const override
 
bool SupportsMapUnmap () const override
 
MemorySourceFlags GetExportFlags () const override
 
MemorySourceFlags GetImportFlags () const override
 
std::vector< CapabilityGetCapabilities (const IConnectableLayer *layer, const IConnectableLayer *connectedLayer, CapabilityClass capabilityClass) override
 
- Public Member Functions inherited from ITensorHandleFactory
virtual ~ITensorHandleFactory ()
 Some TensorHandleFactory decisions are deferred to run-time. More...
 
virtual bool SupportsInPlaceComputation () const
 

Static Public Member Functions

static const FactoryIdGetIdStatic ()
 

Static Public Attributes

static const FactoryId m_Id
 
- Static Public Attributes inherited from ITensorHandleFactory
static const FactoryId LegacyFactoryId = "armnn_legacy_factory"
 
static const FactoryId DeferredFactoryId = "armnn_deferred_factory"
 Use the workload factory to create the tensor handle. More...
 

Additional Inherited Members

- Public Types inherited from ITensorHandleFactory
using FactoryId = std::string
 

Detailed Description

This factory creates ClImportTensorHandles that refer to imported memory tensors.

Definition at line 22 of file ClImportTensorHandleFactory.hpp.

Constructor & Destructor Documentation

◆ ClImportTensorHandleFactory()

ClImportTensorHandleFactory ( MemorySourceFlags  importFlags,
MemorySourceFlags  exportFlags 
)
inline

Create a tensor handle factory for tensors that will be imported or exported.

Parameters
importFlags
exportFlags

Definition at line 33 of file ClImportTensorHandleFactory.hpp.

34  : m_ImportFlags(importFlags)
35  , m_ExportFlags(exportFlags)
36  {}

Member Function Documentation

◆ CreateSubTensorHandle()

std::unique_ptr< ITensorHandle > CreateSubTensorHandle ( ITensorHandle parent,
const TensorShape subTensorShape,
const unsigned int *  subTensorOrigin 
) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 20 of file ClImportTensorHandleFactory.cpp.

22 {
24  arm_compute::TensorShape shape = armcomputetensorutils::BuildArmComputeTensorShape(subTensorShape);
25 
26  coords.set_num_dimensions(subTensorShape.GetNumDimensions());
27  for (unsigned int i = 0; i < subTensorShape.GetNumDimensions(); ++i)
28  {
29  // Arm compute indexes tensor coords in reverse order.
30  unsigned int revertedIndex = subTensorShape.GetNumDimensions() - i - 1;
31  coords.set(i, armnn::numeric_cast<int>(subTensorOrigin[revertedIndex]));
32  }
33 
34  const arm_compute::TensorShape parentShape = armcomputetensorutils::BuildArmComputeTensorShape(parent.GetShape());
35 
36  // In order for ACL to support subtensors the concat axis cannot be on x or y and the values of x and y
37  // must match the parent shapes
38  if (coords.x() != 0 || coords.y() != 0)
39  {
40  return nullptr;
41  }
42  if ((parentShape.x() != shape.x()) || (parentShape.y() != shape.y()))
43  {
44  return nullptr;
45  }
46 
47  if (!::arm_compute::error_on_invalid_subtensor(__func__, __FILE__, __LINE__, parentShape, coords, shape))
48  {
49  return nullptr;
50  }
51 
52  return std::make_unique<ClImportSubTensorHandle>(
53  PolymorphicDowncast<IClTensorHandle*>(&parent), shape, coords);
54 }

◆ CreateTensorHandle() [1/4]

std::unique_ptr< ITensorHandle > CreateTensorHandle ( const TensorInfo tensorInfo) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 56 of file ClImportTensorHandleFactory.cpp.

57 {
58  std::unique_ptr<ClImportTensorHandle> tensorHandle = std::make_unique<ClImportTensorHandle>(tensorInfo,
59  GetImportFlags());
60  return tensorHandle;
61 }

References ClImportTensorHandleFactory::GetImportFlags().

Referenced by ClImportTensorHandleFactory::CreateTensorHandle().

◆ CreateTensorHandle() [2/4]

std::unique_ptr< ITensorHandle > CreateTensorHandle ( const TensorInfo tensorInfo,
const bool  IsMemoryManaged 
) const
overridevirtual

Utility Functions for backends which require TensorHandles to have unmanaged memory.

These should be overloaded if required to facilitate direct import of input tensors and direct export of output tensors.

Reimplemented from ITensorHandleFactory.

Definition at line 72 of file ClImportTensorHandleFactory.cpp.

74 {
75  if (IsMemoryManaged)
76  {
77  throw InvalidArgumentException("ClImportTensorHandleFactory does not support memory managed tensors.");
78  }
79  return CreateTensorHandle(tensorInfo);
80 }

References ClImportTensorHandleFactory::CreateTensorHandle().

◆ CreateTensorHandle() [3/4]

std::unique_ptr< ITensorHandle > CreateTensorHandle ( const TensorInfo tensorInfo,
DataLayout  dataLayout 
) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 63 of file ClImportTensorHandleFactory.cpp.

65 {
66  std::unique_ptr<ClImportTensorHandle> tensorHandle = std::make_unique<ClImportTensorHandle>(tensorInfo,
67  dataLayout,
68  GetImportFlags());
69  return tensorHandle;
70 }

References ClImportTensorHandleFactory::GetImportFlags().

◆ CreateTensorHandle() [4/4]

std::unique_ptr< ITensorHandle > CreateTensorHandle ( const TensorInfo tensorInfo,
DataLayout  dataLayout,
const bool  IsMemoryManaged 
) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 82 of file ClImportTensorHandleFactory.cpp.

85 {
86  if (IsMemoryManaged)
87  {
88  throw InvalidArgumentException("ClImportTensorHandleFactory does not support memory managed tensors.");
89  }
90  return CreateTensorHandle(tensorInfo, dataLayout);
91 }

References ClImportTensorHandleFactory::CreateTensorHandle().

◆ GetCapabilities()

std::vector< Capability > GetCapabilities ( const IConnectableLayer layer,
const IConnectableLayer connectedLayer,
CapabilityClass  capabilityClass 
)
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 124 of file ClImportTensorHandleFactory.cpp.

127 {
128  IgnoreUnused(layer);
129  IgnoreUnused(connectedLayer);
130  std::vector<Capability> capabilities;
131  if (capabilityClass == CapabilityClass::FallbackImportDisabled)
132  {
133  Capability paddingCapability(CapabilityClass::FallbackImportDisabled, true);
134  capabilities.push_back(paddingCapability);
135  }
136  return capabilities;
137 }

References armnn::FallbackImportDisabled, and armnn::IgnoreUnused().

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 114 of file ClImportTensorHandleFactory.cpp.

115 {
116  return m_ExportFlags;
117 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 99 of file ClImportTensorHandleFactory.cpp.

100 {
101  return GetIdStatic();
102 }

References ClImportTensorHandleFactory::GetIdStatic().

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 93 of file ClImportTensorHandleFactory.cpp.

94 {
95  static const FactoryId s_Id(ClImportTensorHandleFactoryId());
96  return s_Id;
97 }

References armnn::ClImportTensorHandleFactoryId().

Referenced by ClBackend::GetHandleFactoryPreferences(), and ClImportTensorHandleFactory::GetId().

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 119 of file ClImportTensorHandleFactory.cpp.

120 {
121  return m_ImportFlags;
122 }

Referenced by ClImportTensorHandleFactory::CreateTensorHandle().

◆ SupportsMapUnmap()

bool SupportsMapUnmap ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 109 of file ClImportTensorHandleFactory.cpp.

110 {
111  return false;
112 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 104 of file ClImportTensorHandleFactory.cpp.

105 {
106  return true;
107 }

Member Data Documentation

◆ m_Id

const FactoryId m_Id
static

Definition at line 25 of file ClImportTensorHandleFactory.hpp.


The documentation for this class was generated from the following files:
armnn::CapabilityClass::FallbackImportDisabled
@ FallbackImportDisabled
armnn::ClImportTensorHandleFactoryId
constexpr const char * ClImportTensorHandleFactoryId()
Definition: ClImportTensorHandleFactory.hpp:14
armnn::ClImportTensorHandleFactory::CreateTensorHandle
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override
Definition: ClImportTensorHandleFactory.cpp:56
armnn::Coordinates
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
Definition: InternalTypes.hpp:15
armnn::ClImportTensorHandleFactory::GetImportFlags
MemorySourceFlags GetImportFlags() const override
Definition: ClImportTensorHandleFactory.cpp:119
armnn::ClImportTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: ClImportTensorHandleFactory.cpp:93
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49