ArmNN
 24.08
NeonTensorHandleFactory Class Reference

#include <NeonTensorHandleFactory.hpp>

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

Public Member Functions

 NeonTensorHandleFactory (std::weak_ptr< NeonMemoryManager > 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=true) const override
 
const FactoryIdGetId () const override
 
bool SupportsInPlaceComputation () const override
 
bool SupportsSubTensors () 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 SupportsMapUnmap () const
 

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 34 of file NeonTensorHandleFactory.hpp.

Constructor & Destructor Documentation

◆ NeonTensorHandleFactory()

NeonTensorHandleFactory ( std::weak_ptr< NeonMemoryManager mgr)
inline

Definition at line 37 of file NeonTensorHandleFactory.hpp.

38  : m_MemoryManager(mgr),
39  m_ImportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc)),
40  m_ExportFlags(static_cast<MemorySourceFlags>(MemorySource::Malloc))
41  {}

References armnn::Malloc.

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 NeonTensorHandleFactory.cpp.

24 {
25  const arm_compute::TensorShape shape = armcomputetensorutils::BuildArmComputeTensorShape(subTensorShape);
26 
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  if (!::arm_compute::error_on_invalid_subtensor(__func__, __FILE__, __LINE__, parentShape, coords, shape))
39  {
40  return nullptr;
41  }
42 
43  return std::make_unique<NeonSubTensorHandle>(
44  PolymorphicDowncast<IAclTensorHandle*>(&parent), shape, coords);
45 }

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 47 of file NeonTensorHandleFactory.cpp.

48 {
49  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, true);
50 }

Referenced by NeonTensorHandleFactory::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 58 of file NeonTensorHandleFactory.cpp.

60 {
61  auto tensorHandle = std::make_unique<NeonTensorHandle>(tensorInfo);
62  if (IsMemoryManaged)
63  {
64  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
65  }
66  // If we are not Managing the Memory then we must be importing
67  tensorHandle->SetImportEnabledFlag(!IsMemoryManaged);
68  tensorHandle->SetImportFlags(GetImportFlags());
69 
70  return tensorHandle;
71 }

References NeonTensorHandleFactory::GetImportFlags().

◆ CreateTensorHandle() [3/4]

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

Implements ITensorHandleFactory.

Definition at line 52 of file NeonTensorHandleFactory.cpp.

54 {
55  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, dataLayout, true);
56 }

References NeonTensorHandleFactory::CreateTensorHandle().

◆ CreateTensorHandle() [4/4]

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

Reimplemented from ITensorHandleFactory.

Definition at line 73 of file NeonTensorHandleFactory.cpp.

76 {
77  auto tensorHandle = std::make_unique<NeonTensorHandle>(tensorInfo, dataLayout);
78  if (IsMemoryManaged)
79  {
80  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
81  }
82  // If we are not Managing the Memory then we must be importing
83  tensorHandle->SetImportEnabledFlag(!IsMemoryManaged);
84  tensorHandle->SetImportFlags(GetImportFlags());
85 
86  return tensorHandle;
87 }

References NeonTensorHandleFactory::GetImportFlags().

◆ GetCapabilities()

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

Reimplemented from ITensorHandleFactory.

Definition at line 120 of file NeonTensorHandleFactory.cpp.

124 {
125  IgnoreUnused(connectedLayer);
126  std::vector<Capability> capabilities;
127  if (capabilityClass == CapabilityClass::PaddingRequired)
128  {
129  auto search = paddingRequiredLayers.find((PolymorphicDowncast<const Layer*>(layer))->GetType());
130  if ( search != paddingRequiredLayers.end())
131  {
132  Capability paddingCapability(CapabilityClass::PaddingRequired, true);
133  capabilities.push_back(paddingCapability);
134  }
135  }
136  return capabilities;
137 }

References armnn::IgnoreUnused(), armnn::PaddingRequired, and armnn::paddingRequiredLayers.

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 110 of file NeonTensorHandleFactory.cpp.

111 {
112  return m_ExportFlags;
113 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 95 of file NeonTensorHandleFactory.cpp.

96 {
97  return GetIdStatic();
98 }

References NeonTensorHandleFactory::GetIdStatic().

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 89 of file NeonTensorHandleFactory.cpp.

90 {
91  static const FactoryId s_Id(NeonTensorHandleFactoryId());
92  return s_Id;
93 }

References armnn::NeonTensorHandleFactoryId().

Referenced by NeonBackend::GetHandleFactoryPreferences(), and NeonTensorHandleFactory::GetId().

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 115 of file NeonTensorHandleFactory.cpp.

116 {
117  return m_ImportFlags;
118 }

Referenced by NeonTensorHandleFactory::CreateTensorHandle().

◆ SupportsInPlaceComputation()

bool SupportsInPlaceComputation ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 100 of file NeonTensorHandleFactory.cpp.

101 {
102  return true;
103 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 105 of file NeonTensorHandleFactory.cpp.

106 {
107  return false;
108 }

The documentation for this class was generated from the following files:
armnn::MemorySource::Malloc
@ Malloc
armnn::NeonTensorHandleFactory::GetImportFlags
MemorySourceFlags GetImportFlags() const override
Definition: NeonTensorHandleFactory.cpp:115
armnn::NeonTensorHandleFactory::GetIdStatic
static const FactoryId & GetIdStatic()
Definition: NeonTensorHandleFactory.cpp:89
armnn::MemorySourceFlags
unsigned int MemorySourceFlags
Definition: MemorySources.hpp:15
armnn::Coordinates
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
Definition: InternalTypes.hpp:15
armnn::paddingRequiredLayers
const std::set< armnn::LayerType > paddingRequiredLayers
Definition: NeonTensorHandleFactory.hpp:16
armnn::NeonTensorHandleFactoryId
constexpr const char * NeonTensorHandleFactoryId()
Definition: NeonTensorHandleFactory.hpp:14
armnn::CapabilityClass::PaddingRequired
@ PaddingRequired
armnn::NeonTensorHandleFactory::CreateTensorHandle
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override
Definition: NeonTensorHandleFactory.cpp:47
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn::ITensorHandleFactory::FactoryId
std::string FactoryId
Definition: ITensorHandleFactory.hpp:49