10 #include <fmt/format.h>
11 #include <mapbox/variant.hpp>
16 template<
typename TContainer>
18 const std::vector<TContainer>& inputDataContainers)
22 const size_t numInputs = inputBindings.size();
23 if (numInputs != inputDataContainers.size())
25 throw armnn::Exception(fmt::format(
"The number of inputs does not match number of "
26 "tensor data containers: {0} != {1}",
28 inputDataContainers.size()));
31 for (
size_t i = 0; i < numInputs; i++)
34 const TContainer& inputData = inputDataContainers[i];
36 mapbox::util::apply_visitor([&](
auto&& value)
38 if (value.size() != inputBinding.second.GetNumElements())
40 throw armnn::Exception(fmt::format(
"The input tensor has incorrect size (expected {0} got {1})",
41 inputBinding.second.GetNumElements(),
47 inputTensors.push_back(std::make_pair(inputBinding.first, inputTensor));
55 template<
typename TContainer>
57 std::vector<TContainer>& outputDataContainers)
61 const size_t numOutputs = outputBindings.size();
62 if (numOutputs != outputDataContainers.size())
65 "of tensor data containers: {0} != {1}",
67 outputDataContainers.size()));
70 for (
size_t i = 0; i < numOutputs; i++)
73 TContainer& outputData = outputDataContainers[i];
75 mapbox::util::apply_visitor([&](
auto&& value)
77 if (value.size() != outputBinding.second.GetNumElements())
79 throw armnn::Exception(
"Output tensor has incorrect size");
82 armnn::Tensor outputTensor(outputBinding.second, value.data());
83 outputTensors.push_back(std::make_pair(outputBinding.first, outputTensor));