ArmNN
 24.02
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 602 of file OnnxParser.cpp.

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

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