ArmNN
 22.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 566 of file OnnxParser.cpp.

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

569 {
570  ARMNN_ASSERT_MSG(bufferPtr != nullptr, fmt::format("Buffer for permutation is null").c_str());
571 
572  std::unique_ptr<T[]> data(new T[tensorInfo.GetNumElements()]);
573 
574  if (permutationVector.has_value() && permutationVector.value().GetSize() > 0)
575  {
576  tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector.value());
577  armnnUtils::Permute(tensorInfo.GetShape(), permutationVector.value(),
578  reinterpret_cast<const T*>(bufferPtr), data.get(), sizeof(T));
579  }
580  else
581  {
582  ::memcpy(data.get(), bufferPtr, tensorInfo.GetNumBytes());
583  }
584 
585  return std::make_pair(ConstTensor(tensorInfo, data.get()), std::move(data));
586 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
unsigned int GetNumBytes() const
Definition: Tensor.cpp:429
void Permute(const armnn::TensorShape &dstShape, const armnn::PermutationVector &mappings, const void *src, void *dst, size_t dataTypeSize)
Definition: Permute.cpp:131
#define ARMNN_ASSERT_MSG(COND, MSG)
Definition: Assert.hpp:15
bool has_value() const noexcept
Definition: Optional.hpp:53
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:327
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition: Permute.cpp:98
unsigned int GetNumElements() const
Definition: Tensor.hpp:196