ArmNN  NotReleased
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
 
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 ()
 
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"
 

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

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

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

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 42 of file NeonTensorHandleFactory.cpp.

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

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

References NeonTensorHandleFactory::CreateTensorHandle().

49 {
50  return NeonTensorHandleFactory::CreateTensorHandle(tensorInfo, dataLayout, true);
51 }
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

Reimplemented from ITensorHandleFactory.

Definition at line 53 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetImportFlags().

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

References NeonTensorHandleFactory::GetImportFlags().

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

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 100 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

101 {
102  return 0;
103 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 90 of file NeonTensorHandleFactory.cpp.

References NeonTensorHandleFactory::GetIdStatic().

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

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

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 84 of file NeonTensorHandleFactory.cpp.

References armnn::NeonTensorHandleFactoryId().

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

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

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 105 of file NeonTensorHandleFactory.cpp.

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

106 {
107  return 0;
108 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 95 of file NeonTensorHandleFactory.cpp.

Referenced by NeonTensorHandleFactory::NeonTensorHandleFactory().

96 {
97  return true;
98 }

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