ArmNN  NotReleased
ClTensorHandleFactory Class Reference

#include <ClTensorHandleFactory.hpp>

Inheritance diagram for ClTensorHandleFactory:
ITensorHandleFactory

Public Member Functions

 ClTensorHandleFactory (std::shared_ptr< ClMemoryManager > 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 ()
 

Static Public Attributes

static const FactoryId m_Id
 
- Static Public Attributes inherited from ITensorHandleFactory
static const FactoryId LegacyFactoryId = "armnn_legacy_factory"
 
static const FactoryId DeferredFactoryId = "armnn_deferred_factory"
 

Additional Inherited Members

- Public Types inherited from ITensorHandleFactory
using FactoryId = std::string
 

Detailed Description

Definition at line 17 of file ClTensorHandleFactory.hpp.

Constructor & Destructor Documentation

◆ ClTensorHandleFactory()

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 22 of file ClTensorHandleFactory.cpp.

Referenced by ClTensorHandleFactory::ClTensorHandleFactory().

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

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 48 of file ClTensorHandleFactory.cpp.

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

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

References ClTensorHandleFactory::CreateTensorHandle().

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

61 {
62  std::unique_ptr<ClTensorHandle> tensorHandle = std::make_unique<ClTensorHandle>(tensorInfo);
63  if (IsMemoryManaged)
64  {
65  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
66  }
67  return tensorHandle;
68 }

◆ 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 70 of file ClTensorHandleFactory.cpp.

73 {
74  std::unique_ptr<ClTensorHandle> tensorHandle = std::make_unique<ClTensorHandle>(tensorInfo, dataLayout);
75  if (IsMemoryManaged)
76  {
77  tensorHandle->SetMemoryGroup(m_MemoryManager->GetInterLayerMemoryGroup());
78  }
79  return tensorHandle;
80 }

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 98 of file ClTensorHandleFactory.cpp.

Referenced by ClTensorHandleFactory::ClTensorHandleFactory().

99 {
100  return m_ExportFlags;
101 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 88 of file ClTensorHandleFactory.cpp.

References ClTensorHandleFactory::GetIdStatic().

Referenced by ClTensorHandleFactory::ClTensorHandleFactory().

89 {
90  return GetIdStatic();
91 }
static const FactoryId & GetIdStatic()

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

Definition at line 82 of file ClTensorHandleFactory.cpp.

References armnn::ClTensorHandleFactoryId().

Referenced by ClTensorHandleFactory::ClTensorHandleFactory(), ClBackend::GetHandleFactoryPreferences(), and ClTensorHandleFactory::GetId().

83 {
84  static const FactoryId s_Id(ClTensorHandleFactoryId());
85  return s_Id;
86 }
constexpr const char * ClTensorHandleFactoryId()

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 103 of file ClTensorHandleFactory.cpp.

Referenced by ClTensorHandleFactory::ClTensorHandleFactory().

104 {
105  return m_ImportFlags;
106 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 93 of file ClTensorHandleFactory.cpp.

Referenced by ClTensorHandleFactory::ClTensorHandleFactory().

94 {
95  return true;
96 }

Member Data Documentation

◆ m_Id

const FactoryId m_Id
static

Definition at line 19 of file ClTensorHandleFactory.hpp.


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