ArmNN
 21.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 506 of file OnnxParser.cpp.

References ARMNN_ASSERT_MSG, CHECK_LOCATION, 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().

509 {
510  ARMNN_ASSERT_MSG(bufferPtr != nullptr, fmt::format("Buffer for permutation is null").c_str());
511 
512  std::unique_ptr<T[]> data(new T[tensorInfo.GetNumElements()]);
513 
514  if (permutationVector.has_value() && permutationVector.value().GetSize() > 0)
515  {
516  tensorInfo = armnnUtils::Permuted(tensorInfo, permutationVector.value());
517  armnnUtils::Permute(tensorInfo.GetShape(), permutationVector.value(),
518  reinterpret_cast<const T*>(bufferPtr), data.get(), sizeof(T));
519  }
520  else
521  {
522  ::memcpy(data.get(), bufferPtr, tensorInfo.GetNumBytes());
523  }
524 
525  return std::make_pair(ConstTensor(tensorInfo, data.get()), std::move(data));
526 }
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