ArmNN
 24.08
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 22 of file ClTensorHandleFactory.cpp.

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

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 58 of file ClTensorHandleFactory.cpp.

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

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

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

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

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

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

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

References ARMNN_LOG, and armnn::warning.

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 110 of file ClTensorHandleFactory.cpp.

111 {
113 }

References armnn::Undefined.

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 100 of file ClTensorHandleFactory.cpp.

101 {
102  return GetIdStatic();
103 }

References ClTensorHandleFactory::GetIdStatic().

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 94 of file ClTensorHandleFactory.cpp.

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

References armnn::ClTensorHandleFactoryId().

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

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 115 of file ClTensorHandleFactory.cpp.

116 {
118 }

References armnn::Undefined.

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 105 of file ClTensorHandleFactory.cpp.

106 {
107  return false;
108 }

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:94
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:58
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