ArmNN
 21.08
NeonTensorHandleFactory Class Reference

#include <NeonTensorHandleFactory.hpp>

Inheritance diagram for NeonTensorHandleFactory:
ITensorHandleFactory

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()

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.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

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 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 47 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::CreateTensorHandle(), NeonTensorHandleFactory::NeonTensorHandleFactory(), and TEST_SUITE().

48 {
49  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, true);
50 }
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override

◆ CreateTensorHandle() [2/4]

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

Implements ITensorHandleFactory.

Definition at line 52 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::CreateTensorHandle().

54 {
55  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, dataLayout, true);
56 }
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override

◆ CreateTensorHandle() [3/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.

References NeonTensorHandleFactory::GetImportFlags().

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 }
MemorySourceFlags GetImportFlags() const override

◆ 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.

References NeonTensorHandleFactory::GetImportFlags().

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 }
MemorySourceFlags GetImportFlags() const override

◆ 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.

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

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

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 }
void IgnoreUnused(Ts &&...)
const std::set< armnn::LayerType > paddingRequiredLayers

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 110 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

111 {
112  return m_ExportFlags;
113 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 95 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetIdStatic().

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

96 {
97  return GetIdStatic();
98 }
static const FactoryId & GetIdStatic()

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 115 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::CreateTensorHandle(), and NeonTensorHandleFactory::NeonTensorHandleFactory().

116 {
117  return m_ImportFlags;
118 }

◆ SupportsInPlaceComputation()

bool SupportsInPlaceComputation ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 100 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

101 {
102  return true;
103 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 105 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

106 {
107  return true;
108 }

The documentation for this class was generated from the following files: