39 const std::string& inputName,
40 const std::string& outputName);
43 const std::string& inputName,
44 const std::string& outputName);
45 void Setup(
const std::map<std::string, armnn::TensorShape>& inputShapes,
46 const std::vector<std::string>& requestedOutputs);
47 void Setup(
const std::map<std::string, armnn::TensorShape>& inputShapes);
50 const std::map<std::string,armnn::TensorShape>& inputShapes,
51 const std::vector<std::string>& requestedOutputs);
56 template <std::
size_t NumOutputDimensions>
57 void RunTest(
const std::vector<float>& inputData,
const std::vector<float>& expectedOutputData);
61 template <std::
size_t NumOutputDimensions>
62 void RunComparisonTest(
const std::map<std::string, std::vector<float>>& inputData,
63 const std::map<std::string, std::vector<uint8_t>>& expectedOutputData);
67 template <std::
size_t NumOutputDimensions,
typename T =
float>
68 void RunTest(
const std::map<std::string, std::vector<float>>& inputData,
69 const std::map<std::string, std::vector<T>>& expectedOutputData);
72 std::unique_ptr<TParser, void(*)(TParser* parser)>
m_Parser;
125 const std::vector<std::string>& requestedOutputs)
127 std::string errorMessage;
135 throw armnn::Exception(fmt::format(
"LoadNetwork failed with error: '{0}' {1}",
208 const std::map<std::string, std::vector<T>>& expectedOutputData)
212 for (
auto&& it : inputData)
215 bindingInfo.second.SetConstant(
true);
216 inputTensors.push_back({ bindingInfo.first,
armnn::ConstTensor(bindingInfo.second, it.second.data()) });
217 if (bindingInfo.second.GetNumElements() != it.second.size())
219 throw armnn::Exception(fmt::format(
"Input tensor {0} is expected to have {1} elements. "
220 "{2} elements supplied. {3}",
222 bindingInfo.second.GetNumElements(),
229 std::map<std::string, std::vector<T>> outputStorage;
231 for (
auto&& it : expectedOutputData)
234 outputStorage.emplace(it.first, std::vector<T>(bindingInfo.second.GetNumElements()));
235 outputTensors.push_back(
236 { bindingInfo.first,
armnn::Tensor(bindingInfo.second, outputStorage.at(it.first).data()) });
242 for (
auto&& it : expectedOutputData)
245 if (bindingInfo.second.GetNumElements() != it.second.size())
247 throw armnn::Exception(fmt::format(
"Output tensor {0} is expected to have {1} elements. "
248 "{2} elements supplied. {3}",
250 bindingInfo.second.GetNumElements(),
259 if (bindingInfo.second.GetShape().GetNumDimensions() == NumOutputDimensions &&
260 bindingInfo.second.GetShape().GetNumDimensions() ==
m_SingleOutputShape.GetNumDimensions())
268 std::stringstream message;
269 message <<
"Output tensor " << it.first <<
" is expected to have "
270 << bindingInfo.second.GetShape() <<
"shape. "
279 throw armnn::Exception(fmt::format(
"Output tensor {0} is expected to have {1} dimensions. "
280 "{2} dimensions supplied. {3}",
282 bindingInfo.second.GetShape().GetNumDimensions(),
288 auto outputExpected = it.second;
289 auto shape = bindingInfo.second.GetShape();
290 if (std::is_same<T, uint8_t>::value)
292 auto result = CompareTensors(outputExpected, outputStorage[it.first], shape, shape,
true);
293 CHECK_MESSAGE(result.m_Result, result.m_Message.str());
297 auto result = CompareTensors(outputExpected, outputStorage[it.first], shape, shape);
298 CHECK_MESSAGE(result.m_Result, result.m_Message.str());
IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptionsOpaque &options=OptimizerOptionsOpaque(), Optional< std::vector< std::string > & > messages=EmptyOptional())
Create an optimized version of the network.
void RunComparisonTest(const std::map< std::string, std::vector< float > > &inputData, const std::map< std::string, std::vector< uint8_t > > &expectedOutputData)
Executes the network with the given input tensor and checks the result against the given output tenso...