ArmNN
 21.05
ClImportTensorHandleFactory Class Reference

This factory creates ClImportTensorHandles that refer to imported memory tensors. More...

#include <ClImportTensorHandleFactory.hpp>

Inheritance diagram for ClImportTensorHandleFactory:
ITensorHandleFactory

Public Member Functions

 ClImportTensorHandleFactory (MemorySourceFlags importFlags, MemorySourceFlags exportFlags)
 Create a tensor handle factory for tensors that will be imported or exported. More...
 
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) const override
 
const FactoryIdGetId () const override
 
bool SupportsSubTensors () const override
 
bool SupportsMapUnmap () 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 SupportsInPlaceComputation () const
 

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"
 Use the workload factory to create the tensor handle. More...
 

Additional Inherited Members

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

Detailed Description

This factory creates ClImportTensorHandles that refer to imported memory tensors.

Definition at line 23 of file ClImportTensorHandleFactory.hpp.

Constructor & Destructor Documentation

◆ ClImportTensorHandleFactory()

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 ClImportTensorHandleFactory.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and ClImportTensorHandleFactory::ClImportTensorHandleFactory().

22 {
24  arm_compute::TensorShape shape = armcomputetensorutils::BuildArmComputeTensorShape(subTensorShape);
25 
26  coords.set_num_dimensions(subTensorShape.GetNumDimensions());
27  for (unsigned int i = 0; i < subTensorShape.GetNumDimensions(); ++i)
28  {
29  // Arm compute indexes tensor coords in reverse order.
30  unsigned int revertedIndex = subTensorShape.GetNumDimensions() - i - 1;
31  coords.set(i, armnn::numeric_cast<int>(subTensorOrigin[revertedIndex]));
32  }
33 
34  const arm_compute::TensorShape parentShape = armcomputetensorutils::BuildArmComputeTensorShape(parent.GetShape());
35 
36  // In order for ACL to support subtensors the concat axis cannot be on x or y and the values of x and y
37  // must match the parent shapes
38  if (coords.x() != 0 || coords.y() != 0)
39  {
40  return nullptr;
41  }
42  if ((parentShape.x() != shape.x()) || (parentShape.y() != shape.y()))
43  {
44  return nullptr;
45  }
46 
47  if (!::arm_compute::error_on_invalid_subtensor(__func__, __FILE__, __LINE__, parentShape, coords, shape))
48  {
49  return nullptr;
50  }
51 
52  return std::make_unique<ClImportSubTensorHandle>(
53  PolymorphicDowncast<IClImportTensorHandle*>(&parent), shape, coords);
54 }
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates

◆ CreateTensorHandle() [1/4]

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

Implements ITensorHandleFactory.

Definition at line 56 of file ClImportTensorHandleFactory.cpp.

References ClImportTensorHandleFactory::GetImportFlags().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), ClImportTensorHandleFactory::ClImportTensorHandleFactory(), and ClImportTensorHandleFactory::CreateTensorHandle().

57 {
58  std::unique_ptr<ClImportTensorHandle> tensorHandle = std::make_unique<ClImportTensorHandle>(tensorInfo,
59  GetImportFlags());
60  return tensorHandle;
61 }
MemorySourceFlags GetImportFlags() const override

◆ CreateTensorHandle() [2/4]

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

Implements ITensorHandleFactory.

Definition at line 63 of file ClImportTensorHandleFactory.cpp.

References ClImportTensorHandleFactory::GetImportFlags().

65 {
66  std::unique_ptr<ClImportTensorHandle> tensorHandle = std::make_unique<ClImportTensorHandle>(tensorInfo,
67  dataLayout,
68  GetImportFlags());
69  return tensorHandle;
70 }
MemorySourceFlags GetImportFlags() 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 72 of file ClImportTensorHandleFactory.cpp.

References ClImportTensorHandleFactory::CreateTensorHandle().

74 {
75  if (IsMemoryManaged)
76  {
77  throw InvalidArgumentException("ClImportTensorHandleFactory does not support memory managed tensors.");
78  }
79  return CreateTensorHandle(tensorInfo);
80 }
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override

◆ CreateTensorHandle() [4/4]

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

Reimplemented from ITensorHandleFactory.

Definition at line 82 of file ClImportTensorHandleFactory.cpp.

References ClImportTensorHandleFactory::CreateTensorHandle().

85 {
86  if (IsMemoryManaged)
87  {
88  throw InvalidArgumentException("ClImportTensorHandleFactory does not support memory managed tensors.");
89  }
90  return CreateTensorHandle(tensorInfo, dataLayout);
91 }
std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const override

◆ GetCapabilities()

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

Reimplemented from ITensorHandleFactory.

Definition at line 124 of file ClImportTensorHandleFactory.cpp.

References armnn::FallbackImportDisabled, and armnn::IgnoreUnused().

Referenced by ClImportTensorHandleFactory::ClImportTensorHandleFactory().

127 {
128  IgnoreUnused(layer);
129  IgnoreUnused(connectedLayer);
130  std::vector<Capability> capabilities;
131  if (capabilityClass == CapabilityClass::FallbackImportDisabled)
132  {
133  Capability paddingCapability(CapabilityClass::FallbackImportDisabled, true);
134  capabilities.push_back(paddingCapability);
135  }
136  return capabilities;
137 }
void IgnoreUnused(Ts &&...)

◆ GetExportFlags()

MemorySourceFlags GetExportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 114 of file ClImportTensorHandleFactory.cpp.

Referenced by ClImportTensorHandleFactory::ClImportTensorHandleFactory().

115 {
116  return m_ExportFlags;
117 }

◆ GetId()

const FactoryId & GetId ( ) const
overridevirtual

◆ GetIdStatic()

const FactoryId & GetIdStatic ( )
static

◆ GetImportFlags()

MemorySourceFlags GetImportFlags ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 119 of file ClImportTensorHandleFactory.cpp.

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

120 {
121  return m_ImportFlags;
122 }

◆ SupportsMapUnmap()

bool SupportsMapUnmap ( ) const
overridevirtual

Reimplemented from ITensorHandleFactory.

Definition at line 109 of file ClImportTensorHandleFactory.cpp.

Referenced by ClImportTensorHandleFactory::ClImportTensorHandleFactory().

110 {
111  return false;
112 }

◆ SupportsSubTensors()

bool SupportsSubTensors ( ) const
overridevirtual

Implements ITensorHandleFactory.

Definition at line 104 of file ClImportTensorHandleFactory.cpp.

Referenced by ClImportTensorHandleFactory::ClImportTensorHandleFactory().

105 {
106  return true;
107 }

Member Data Documentation

◆ m_Id

const FactoryId m_Id
static

Definition at line 26 of file ClImportTensorHandleFactory.hpp.


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