ArmNN
 24.02
GpuFsaTensorHandleFactory Class Reference

#include <GpuFsaTensorHandleFactory.hpp>

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

Public Member Functions

 GpuFsaTensorHandleFactory (std::shared_ptr< GpuFsaMemoryManager > mgr)
 
std::unique_ptr< ITensorHandleCreateSubTensorHandle (ITensorHandle &parent, TensorShape const &subTensorShape, unsigned int const *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 ()
 

Additional Inherited Members

- Public Types inherited from ITensorHandleFactory
using FactoryId = std::string
 
- 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...
 

Detailed Description

Definition at line 16 of file GpuFsaTensorHandleFactory.hpp.

Constructor & Destructor Documentation

◆ GpuFsaTensorHandleFactory()

GpuFsaTensorHandleFactory ( std::shared_ptr< GpuFsaMemoryManager mgr)
inline

Definition at line 20 of file GpuFsaTensorHandleFactory.hpp.

21  : m_MemoryManager(mgr)
22  {}

Member Function Documentation

◆ CreateSubTensorHandle()

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

Implements ITensorHandleFactory.

Definition at line 14 of file GpuFsaTensorHandleFactory.cpp.

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

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 50 of file GpuFsaTensorHandleFactory.cpp.

51 {
52  return GpuFsaTensorHandleFactory::CreateTensorHandle(tensorInfo, true);
53 }

Referenced by GpuFsaTensorHandleFactory::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 61 of file GpuFsaTensorHandleFactory.cpp.

63 {
64  std::unique_ptr<GpuFsaTensorHandle> tensorHandle = std::make_unique<GpuFsaTensorHandle>(tensorInfo);
65  if (!IsMemoryManaged)
66  {
67  ARMNN_LOG(warning) << "GpuFsaTensorHandleFactory only has support for memory managed.";
68  }
69  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
70  return tensorHandle;
71 }

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 55 of file GpuFsaTensorHandleFactory.cpp.

57 {
58  return GpuFsaTensorHandleFactory::CreateTensorHandle(tensorInfo, dataLayout, true);
59 }

References GpuFsaTensorHandleFactory::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 73 of file GpuFsaTensorHandleFactory.cpp.

76 {
77  std::unique_ptr<GpuFsaTensorHandle> tensorHandle = std::make_unique<GpuFsaTensorHandle>(tensorInfo, dataLayout);
78  if (!IsMemoryManaged)
79  {
80  ARMNN_LOG(warning) << "GpuFsaTensorHandleFactory only has support for memory managed.";
81  }
82  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
83  return tensorHandle;
84 }

References ARMNN_LOG, and armnn::warning.

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 102 of file GpuFsaTensorHandleFactory.cpp.

103 {
105 }

References armnn::Undefined.

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 92 of file GpuFsaTensorHandleFactory.cpp.

93 {
94  return GetIdStatic();
95 }

References GpuFsaTensorHandleFactory::GetIdStatic().

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 86 of file GpuFsaTensorHandleFactory.cpp.

87 {
88  static const FactoryId s_Id(GpuFsaTensorHandleFactoryId());
89  return s_Id;
90 }

References armnn::GpuFsaTensorHandleFactoryId().

Referenced by GpuFsaBackend::GetHandleFactoryPreferences(), and GpuFsaTensorHandleFactory::GetId().

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 107 of file GpuFsaTensorHandleFactory.cpp.

108 {
110 }

References armnn::Undefined.

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 97 of file GpuFsaTensorHandleFactory.cpp.

98 {
99  return true;
100 }

The documentation for this class was generated from the following files:
armnn::GpuFsaTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: GpuFsaTensorHandleFactory.cpp:86
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
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::GpuFsaTensorHandleFactoryId
constexpr const char * GpuFsaTensorHandleFactoryId()
Definition: GpuFsaTensorHandleFactory.hpp:14
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49
armnn::GpuFsaTensorHandleFactory::CreateTensorHandle
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override
Definition: GpuFsaTensorHandleFactory.cpp:50