ArmNN
 24.02
ClTensorHandleFactory Class Reference

#include <ClTensorHandleFactory.hpp>

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

Public Member Functions

 ClTensorHandleFactory (std::shared_ptr< ClMemoryManager > mgr)
 
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
 
MemorySourceFlags GetExportFlags () const override
 
MemorySourceFlags GetImportFlags () const override
 
- Public Member Functions inherited from ITensorHandleFactory
virtual ~ITensorHandleFactory ()
 Some TensorHandleFactory decisions are deferred to run-time. More...
 
virtual bool SupportsInPlaceComputation () const
 
virtual bool SupportsMapUnmap () const
 
virtual std::vector< CapabilityGetCapabilities (const IConnectableLayer *layer, const IConnectableLayer *connectedLayer, CapabilityClass capabilityClass)
 

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

Definition at line 20 of file ClTensorHandleFactory.hpp.

Constructor & Destructor Documentation

◆ ClTensorHandleFactory()

ClTensorHandleFactory ( std::shared_ptr< ClMemoryManager mgr)
inline

Definition at line 25 of file ClTensorHandleFactory.hpp.

26  : m_MemoryManager(mgr)
27  {}

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 21 of file ClTensorHandleFactory.cpp.

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

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 57 of file ClTensorHandleFactory.cpp.

58 {
59  return ClTensorHandleFactory::CreateTensorHandle(tensorInfo, true);
60 }

Referenced by ClTensorHandleFactory::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 68 of file ClTensorHandleFactory.cpp.

70 {
71  std::unique_ptr<ClTensorHandle> tensorHandle = std::make_unique<ClTensorHandle>(tensorInfo);
72  if (!IsMemoryManaged)
73  {
74  ARMNN_LOG(warning) << "ClTensorHandleFactory only has support for memory managed.";
75  }
76  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
77  return tensorHandle;
78 }

References ARMNN_LOG, and armnn::warning.

◆ CreateTensorHandle() [3/4]

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

Implements ITensorHandleFactory.

Definition at line 62 of file ClTensorHandleFactory.cpp.

64 {
65  return ClTensorHandleFactory::CreateTensorHandle(tensorInfo, dataLayout, true);
66 }

References ClTensorHandleFactory::CreateTensorHandle().

◆ CreateTensorHandle() [4/4]

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

Reimplemented from ITensorHandleFactory.

Definition at line 80 of file ClTensorHandleFactory.cpp.

83 {
84  std::unique_ptr<ClTensorHandle> tensorHandle = std::make_unique<ClTensorHandle>(tensorInfo, dataLayout);
85  if (!IsMemoryManaged)
86  {
87  ARMNN_LOG(warning) << "ClTensorHandleFactory only has support for memory managed.";
88  }
89  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
90  return tensorHandle;
91 }

References ARMNN_LOG, and armnn::warning.

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 109 of file ClTensorHandleFactory.cpp.

110 {
112 }

References armnn::Undefined.

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 99 of file ClTensorHandleFactory.cpp.

100 {
101  return GetIdStatic();
102 }

References ClTensorHandleFactory::GetIdStatic().

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 93 of file ClTensorHandleFactory.cpp.

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

References armnn::ClTensorHandleFactoryId().

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

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 114 of file ClTensorHandleFactory.cpp.

115 {
117 }

References armnn::Undefined.

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 104 of file ClTensorHandleFactory.cpp.

105 {
106  return false;
107 }

Member Data Documentation

◆ m_Id

const FactoryId m_Id
static

Definition at line 23 of file ClTensorHandleFactory.hpp.


The documentation for this class was generated from the following files:
armnn::ClTensorHandleFactoryId
constexpr const char * ClTensorHandleFactoryId()
Definition: ClTensorHandleFactory.hpp:15
armnn::ClTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: ClTensorHandleFactory.cpp:93
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::ClTensorHandleFactory::CreateTensorHandle
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override
Definition: ClTensorHandleFactory.cpp:57
armnn::Coordinates
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
Definition: InternalTypes.hpp:15
ARMNN_LOG
#define ARMNN_LOG(severity)
Definition: Logging.hpp:212
armnn::MemorySource::Undefined
@ Undefined
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49