ArmNN
 20.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 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 final
 

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 35 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 19 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

23 {
24  const arm_compute::TensorShape shape = armcomputetensorutils::BuildArmComputeTensorShape(subTensorShape);
25 
27  coords.set_num_dimensions(subTensorShape.GetNumDimensions());
28  for (unsigned int i = 0; i < subTensorShape.GetNumDimensions(); ++i)
29  {
30  // Arm compute indexes tensor coords in reverse order.
31  unsigned int revertedIndex = subTensorShape.GetNumDimensions() - i - 1;
32  coords.set(i, boost::numeric_cast<int>(subTensorOrigin[revertedIndex]));
33  }
34 
35  const arm_compute::TensorShape parentShape = armcomputetensorutils::BuildArmComputeTensorShape(parent.GetShape());
36 
37  if (!::arm_compute::error_on_invalid_subtensor(__func__, __FILE__, __LINE__, parentShape, coords, shape))
38  {
39  return nullptr;
40  }
41 
42  return std::make_unique<NeonSubTensorHandle>(
43  PolymorphicDowncast<IAclTensorHandle*>(&parent), shape, coords);
44 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 46 of file NeonTensorHandleFactory.cpp.

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

47 {
48  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, true);
49 }
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 51 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::CreateTensorHandle().

53 {
54  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, dataLayout, true);
55 }
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 57 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetImportFlags().

59 {
60  auto tensorHandle = std::make_unique<NeonTensorHandle>(tensorInfo);
61  if (IsMemoryManaged)
62  {
63  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
64  }
65  // If we are not Managing the Memory then we must be importing
66  tensorHandle->SetImportEnabledFlag(!IsMemoryManaged);
67  tensorHandle->SetImportFlags(GetImportFlags());
68 
69  return tensorHandle;
70 }
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 72 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetImportFlags().

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

◆ GetCapabilities()

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

Reimplemented from ITensorHandleFactory.

Definition at line 114 of file NeonTensorHandleFactory.cpp.

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

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

118 {
119  IgnoreUnused(connectedLayer);
120  std::vector<Capability> capabilities;
121  if (capabilityClass == CapabilityClass::PaddingRequired)
122  {
123  auto search = paddingRequiredLayers.find((PolymorphicDowncast<const Layer*>(layer))->GetType());
124  if ( search != paddingRequiredLayers.end())
125  {
126  Capability paddingCapability(CapabilityClass::PaddingRequired, true);
127  capabilities.push_back(paddingCapability);
128  }
129  }
130  return capabilities;
131 }
void IgnoreUnused(Ts &&...)
const std::set< armnn::LayerType > paddingRequiredLayers

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 104 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

105 {
106  return m_ExportFlags;
107 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 94 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetIdStatic().

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

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

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 88 of file NeonTensorHandleFactory.cpp.

References armnn::NeonTensorHandleFactoryId().

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

89 {
90  static const FactoryId s_Id(NeonTensorHandleFactoryId());
91  return s_Id;
92 }
constexpr const char * NeonTensorHandleFactoryId()

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 109 of file NeonTensorHandleFactory.cpp.

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

110 {
111  return m_ImportFlags;
112 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 99 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

100 {
101  return true;
102 }

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