ArmNN
 25.11
Loading...
Searching...
No Matches
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()

template<typename T>
std::pair< armnn::ConstTensor, std::unique_ptr< T[]> > 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}
#define CHECK_LOCATION()
bool has_value() const noexcept
Definition Optional.hpp:53
const TensorShape & GetShape() const
Definition Tensor.hpp:193
unsigned int GetNumElements() const
Definition Tensor.hpp:198
unsigned int GetNumBytes() const
Definition Tensor.cpp:427
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
Definition Permute.cpp:125

References CHECK_LOCATION, TensorInfo::GetNumBytes(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), OptionalBase::has_value(), armnn::Permute, armnnUtils::Permuted(), and OptionalReferenceSwitch< IsReference, T >::value().