MCPcopy Create free account
hub / github.com/ARM-software/armnn / CreateConstTensorImpl

Function CreateConstTensorImpl

src/armnnOnnxParser/OnnxParser.cpp:603–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

601
602template<typename T>
603std::pair<armnn::ConstTensor, std::unique_ptr<T[]>>
604CreateConstTensorImpl(const T* bufferPtr,
605 armnn::TensorInfo& tensorInfo,
606 const armnn::Optional<armnn::PermutationVector&> permutationVector)
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}
628
629std::pair<ConstTensor, std::unique_ptr<float[]>>
630OnnxParserImpl::CreateConstTensor(const std::string name,

Callers

nothing calls this directly

Calls 13

ParseExceptionClass · 0.85
formatEnum · 0.85
PermutedFunction · 0.85
PermuteFunction · 0.85
ConstTensorClass · 0.50
AsStringMethod · 0.45
GetNumElementsMethod · 0.45
has_valueMethod · 0.45
GetSizeMethod · 0.45
valueMethod · 0.45
GetShapeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected