| 601 | |
| 602 | template<typename T> |
| 603 | std::pair<armnn::ConstTensor, std::unique_ptr<T[]>> |
| 604 | CreateConstTensorImpl(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 | |
| 629 | std::pair<ConstTensor, std::unique_ptr<float[]>> |
| 630 | OnnxParserImpl::CreateConstTensor(const std::string name, |
nothing calls this directly
no test coverage detected