ArmNN
 24.08
armnnOnnxParser Namespace Reference

Classes

class  IOnnxParser
 
class  OnnxParserImpl
 

Typedefs

using BindingPointInfo = armnn::BindingPointInfo
 
using IOnnxParserPtr = std::unique_ptr< IOnnxParser, void(*)(IOnnxParser *parser)>
 
using ModelPtr = std::unique_ptr< onnx::ModelProto >
 

Functions

template<typename T >
std::pair< armnn::ConstTensor, std::unique_ptr< T[]> > CreateConstTensorImpl (const T *bufferPtr, armnn::TensorInfo &tensorInfo, const armnn::Optional< armnn::PermutationVector & > permutationVector)
 

Typedef Documentation

◆ BindingPointInfo

Definition at line 17 of file IOnnxParser.hpp.

◆ IOnnxParserPtr

using IOnnxParserPtr = std::unique_ptr<IOnnxParser, void(*)(IOnnxParser* parser)>

Definition at line 21 of file IOnnxParser.hpp.

◆ ModelPtr

using ModelPtr = std::unique_ptr<onnx::ModelProto>

Definition at line 23 of file OnnxParser.hpp.

Function Documentation

◆ CreateConstTensorImpl()

std::pair<armnn::ConstTensor, std::unique_ptr<T[]> > armnnOnnxParser::CreateConstTensorImpl ( const T *  bufferPtr,
armnn::TensorInfo tensorInfo,
const armnn::Optional< armnn::PermutationVector & >  permutationVector 
)

Definition at line 604 of file OnnxParser.cpp.

607 {
608  if (bufferPtr == nullptr)
609  {
610  throw armnn::ParseException(fmt::format("Buffer for permutation is null {}", CHECK_LOCATION().AsString()));
611  }
612 
613  std::unique_ptr<T[]> data(new T[tensorInfo.GetNumElements()]);
614 
615  if (permutationVector.has_value() && permutationVector.value().GetSize() > 0)
616  {
617  tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector.value());
618  armnnUtils::Permute(tensorInfo.GetShape(), permutationVector.value(),
619  reinterpret_cast<const T*>(bufferPtr), data.get(), sizeof(T));
620  }
621  else
622  {
623  ::memcpy(data.get(), bufferPtr, tensorInfo.GetNumBytes());
624  }
625 
626  return std::make_pair(ConstTensor(tensorInfo, data.get()), std::move(data));
627 }

References CHECK_LOCATION, TensorInfo::GetNumBytes(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), PermutationVector::GetSize(), OptionalBase::has_value(), armnnUtils::Permute(), armnnUtils::Permuted(), and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

armnn::TensorInfo::GetNumElements
unsigned int GetNumElements() const
Definition: Tensor.hpp:198
armnn::TensorInfo::GetNumBytes
unsigned int GetNumBytes() const
Definition: Tensor.cpp:427
CHECK_LOCATION
#define CHECK_LOCATION()
Definition: Exceptions.hpp:203
armnnUtils::Permute
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:164
armnnUtils::Permuted
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:125
armnn::TensorInfo::GetShape
const TensorShape & GetShape() const
Definition: Tensor.hpp:193
armnn::ParseException
Definition: Exceptions.hpp:92
armnn::ConstTensor
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:329
armnn::OptionalReferenceSwitch< std::is_reference< T >::value, T >::value
const T & value() const
Definition: Optional.hpp:146
armnn::OptionalBase::has_value
bool has_value() const noexcept
Definition: Optional.hpp:53