ArmNN
 24.02
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 92 of file ConversionUtils.hpp.

Constructor & Destructor Documentation

◆ ConstTensorPin() [1/4]

ConstTensorPin ( bool  optional = false)

Definition at line 82 of file ConversionUtils.cpp.

83  : m_Optional(optional)
84 {}

◆ ConstTensorPin() [2/4]

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

Definition at line 86 of file ConversionUtils.cpp.

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

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 122 of file ConversionUtils.cpp.

123 {
124  return m_ConstTensor;
125 }

Referenced by armnn_driver::ConvertToLayerInputHandle().

◆ GetConstTensorPtr()

const armnn::ConstTensor * GetConstTensorPtr ( ) const

Definition at line 127 of file ConversionUtils.cpp.

128 {
129  if (IsValid() && m_ConstTensor.GetNumElements() > 0)
130  {
131  return &m_ConstTensor;
132  }
133  // tensor is either invalid, or has no elements (indicating an optional tensor that was not provided)
134  return nullptr;
135 }

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

◆ IsOptional()

bool IsOptional ( ) const

Definition at line 117 of file ConversionUtils.cpp.

118 {
119  return m_Optional;
120 }

◆ IsValid()

bool IsValid ( ) const

Definition at line 112 of file ConversionUtils.cpp.

113 {
114  return m_ConstTensor.GetMemoryArea() != nullptr;
115 }

References BaseTensor< MemoryType >::GetMemoryArea().

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


The documentation for this class was generated from the following files:
armnn::BaseTensor::GetMemoryArea
MemoryType GetMemoryArea() const
Definition: Tensor.hpp:307
armnn::TensorInfo::GetNumBytes
unsigned int GetNumBytes() const
Definition: Tensor.cpp:427
armnn::BaseTensor::GetNumElements
unsigned int GetNumElements() const
Definition: Tensor.hpp:305
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::PermutationVector::GetSize
SizeType GetSize() const
Definition: Types.hpp:357
armnn::IgnoreUnused
void IgnoreUnused(Ts &&...)
Definition: IgnoreUnused.hpp:14
armnn::ConstTensor
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:329
armnn_driver::ConstTensorPin::IsValid
bool IsValid() const
Definition: ConversionUtils.cpp:112