ArmNN
 23.05
ConstTensorPin Class Reference

#include <ConversionUtils.hpp>

Public Member Functions

 ConstTensorPin (bool optional=false)
 
 ConstTensorPin (armnn::TensorInfo &tensorInfo, const void *valueStart, uint32_t numBytes, const armnn::PermutationVector &mappings)
 
 ConstTensorPin (const ConstTensorPin &other)=delete
 
 ConstTensorPin (ConstTensorPin &&other)=default
 
bool IsValid () const
 
bool IsOptional () const
 
const armnn::ConstTensorGetConstTensor () const
 
const armnn::ConstTensorGetConstTensorPtr () const
 

Detailed Description

Definition at line 90 of file ConversionUtils.hpp.

Constructor & Destructor Documentation

◆ ConstTensorPin() [1/4]

ConstTensorPin ( bool  optional = false)

Definition at line 75 of file ConversionUtils.cpp.

76  : m_Optional(optional)
77 {}

◆ ConstTensorPin() [2/4]

ConstTensorPin ( armnn::TensorInfo tensorInfo,
const void *  valueStart,
uint32_t  numBytes,
const armnn::PermutationVector mappings 
)

Definition at line 79 of file ConversionUtils.cpp.

83  : m_Optional(false)
84 {
85  armnn::IgnoreUnused(numBytes);
86  if (tensorInfo.GetNumBytes() != numBytes)
87  {
88  VLOG(DRIVER) << "The size of ConstTensor does not match its TensorInfo.";
89  }
90 
91  const bool needsSwizzling = (mappings.GetSize() > 0);
92  if (needsSwizzling)
93  {
94  m_SwizzledTensorData.resize(tensorInfo.GetNumBytes());
95  SwizzleAndroidNn4dTensorToArmNn(tensorInfo, valueStart, m_SwizzledTensorData.data(), mappings);
96 
97  m_ConstTensor = armnn::ConstTensor(tensorInfo, m_SwizzledTensorData.data());
98  }
99  else
100  {
101  m_ConstTensor = armnn::ConstTensor(tensorInfo, valueStart);
102  }
103 }

References TensorInfo::GetNumBytes(), PermutationVector::GetSize(), armnn::IgnoreUnused(), and armnn_driver::SwizzleAndroidNn4dTensorToArmNn().

◆ ConstTensorPin() [3/4]

ConstTensorPin ( const ConstTensorPin other)
delete

◆ ConstTensorPin() [4/4]

ConstTensorPin ( ConstTensorPin &&  other)
default

Member Function Documentation

◆ GetConstTensor()

const armnn::ConstTensor & GetConstTensor ( ) const

Definition at line 115 of file ConversionUtils.cpp.

116 {
117  return m_ConstTensor;
118 }

Referenced by armnn_driver::ConvertToLayerInputHandle().

◆ GetConstTensorPtr()

const armnn::ConstTensor * GetConstTensorPtr ( ) const

Definition at line 120 of file ConversionUtils.cpp.

121 {
122  if (IsValid() && m_ConstTensor.GetNumElements() > 0)
123  {
124  return &m_ConstTensor;
125  }
126  // tensor is either invalid, or has no elements (indicating an optional tensor that was not provided)
127  return nullptr;
128 }

References BaseTensor< MemoryType >::GetNumElements(), and ConstTensorPin::IsValid().

◆ IsOptional()

bool IsOptional ( ) const

Definition at line 110 of file ConversionUtils.cpp.

111 {
112  return m_Optional;
113 }

◆ IsValid()

bool IsValid ( ) const

Definition at line 105 of file ConversionUtils.cpp.

106 {
107  return m_ConstTensor.GetMemoryArea() != nullptr;
108 }

References BaseTensor< MemoryType >::GetMemoryArea().

Referenced by armnn_driver::ConvertToLayerInputHandle(), and ConstTensorPin::GetConstTensorPtr().


The documentation for this class was generated from the following files:
armnn_driver::SwizzleAndroidNn4dTensorToArmNn
void SwizzleAndroidNn4dTensorToArmNn(armnn::TensorInfo &tensorInfo, const void *input, void *output, const armnn::PermutationVector &mappings)
Swizzles tensor data in input according to the dimension mappings.
Definition: CanonicalUtils.cpp:40
armnn::ConstTensor
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn::PermutationVector::GetSize
SizeType GetSize() const
Definition: Types.hpp:349
armnn::TensorInfo::GetNumBytes
unsigned int GetNumBytes() const
Definition: Tensor.cpp:427
armnn_driver::ConstTensorPin::IsValid
bool IsValid() const
Definition: ConversionUtils.cpp:105
armnn::BaseTensor::GetNumElements
unsigned int GetNumElements() const
Definition: Tensor.hpp:303
armnn::BaseTensor::GetMemoryArea
MemoryType GetMemoryArea() const
Definition: Tensor.hpp:305