ArmNN
 22.11
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.

Referenced by armnn_driver::ConvertOperandToConstTensorPin(), and armnn_driver::DequantizeAndMakeConstTensorPin().

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.

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

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 }
unsigned int GetNumBytes() const
Definition: Tensor.cpp:427
void IgnoreUnused(Ts &&...)
SizeType GetSize() const
Definition: Types.hpp:338
void SwizzleAndroidNn4dTensorToArmNn(armnn::TensorInfo &tensorInfo, const void *input, void *output, const armnn::PermutationVector &mappings)
Swizzles tensor data in input according to the dimension mappings.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327

◆ 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.

Referenced by Converter::ConvertOperation(), and armnn_driver::ConvertToLayerInputHandle().

116 {
117  return m_ConstTensor;
118 }

◆ GetConstTensorPtr()

const armnn::ConstTensor * GetConstTensorPtr ( ) const

Definition at line 120 of file ConversionUtils.cpp.

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

Referenced by Converter::ConvertOperation().

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 }
unsigned int GetNumElements() const
Definition: Tensor.hpp:303

◆ IsOptional()

bool IsOptional ( ) const

Definition at line 110 of file ConversionUtils.cpp.

Referenced by Converter::ConvertOperation().

111 {
112  return m_Optional;
113 }

◆ IsValid()

bool IsValid ( ) const

Definition at line 105 of file ConversionUtils.cpp.

References BaseTensor< MemoryType >::GetMemoryArea().

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

106 {
107  return m_ConstTensor.GetMemoryArea() != nullptr;
108 }
MemoryType GetMemoryArea() const
Definition: Tensor.hpp:305

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