ArmNN
 20.05
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=true) 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
 
- 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 16 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 17 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

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

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 43 of file NeonTensorHandleFactory.cpp.

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

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

References NeonTensorHandleFactory::CreateTensorHandle().

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

◆ CreateTensorHandle() [3/4]

std::unique_ptr< ITensorHandle > CreateTensorHandle ( const TensorInfo tensorInfo,
const bool  IsMemoryManaged = true 
) 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 54 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetImportFlags().

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

References NeonTensorHandleFactory::GetImportFlags().

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

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 101 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

102 {
103  return 0;
104 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 91 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetIdStatic().

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

92 {
93  return GetIdStatic();
94 }
static const FactoryId & GetIdStatic()

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 85 of file NeonTensorHandleFactory.cpp.

References armnn::NeonTensorHandleFactoryId().

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

86 {
87  static const FactoryId s_Id(NeonTensorHandleFactoryId());
88  return s_Id;
89 }
constexpr const char * NeonTensorHandleFactoryId()

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 106 of file NeonTensorHandleFactory.cpp.

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

107 {
108  return 0;
109 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 96 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

97 {
98  return true;
99 }

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