Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
Sadik Armagan | a9c2ce1 | 2020-07-14 10:02:22 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 5 | |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 6 | #include "NetworkExecutionUtils/NetworkExecutionUtils.hpp" |
| 7 | #include "ExecuteNetworkProgramOptions.hpp" |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 8 | #include <armnn/IAsyncExecutionCallback.hpp> |
| 9 | #include <AsyncExecutionCallback.hpp> |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 10 | |
| 11 | #include <armnn/Logging.hpp> |
David Monahan | 6bb47a7 | 2021-10-22 12:57:28 +0100 | [diff] [blame^] | 12 | #include <armnn/Utils.hpp> |
Rob Hughes | 9542f90 | 2021-07-14 09:48:54 +0100 | [diff] [blame] | 13 | #include <armnnUtils/Filesystem.hpp> |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 14 | #include <InferenceTest.hpp> |
| 15 | |
| 16 | #if defined(ARMNN_SERIALIZER) |
| 17 | #include "armnnDeserializer/IDeserializer.hpp" |
| 18 | #endif |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 19 | #if defined(ARMNN_TF_LITE_PARSER) |
| 20 | #include "armnnTfLiteParser/ITfLiteParser.hpp" |
| 21 | #endif |
| 22 | #if defined(ARMNN_ONNX_PARSER) |
| 23 | #include "armnnOnnxParser/IOnnxParser.hpp" |
| 24 | #endif |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 25 | #if defined(ARMNN_TFLITE_DELEGATE) |
| 26 | #include <armnn_delegate.hpp> |
| 27 | #include <DelegateOptions.hpp> |
| 28 | |
| 29 | #include <tensorflow/lite/builtin_ops.h> |
| 30 | #include <tensorflow/lite/c/builtin_op_data.h> |
| 31 | #include <tensorflow/lite/c/common.h> |
| 32 | #include <tensorflow/lite/optional_debug_tools.h> |
| 33 | #include <tensorflow/lite/kernels/builtin_op_kernels.h> |
| 34 | #include <tensorflow/lite/interpreter.h> |
| 35 | #include <tensorflow/lite/kernels/register.h> |
| 36 | #endif |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 37 | |
| 38 | #include <future> |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 39 | |
| 40 | /** |
| 41 | * Given a measured duration and a threshold time tell the user whether we succeeded or not. |
| 42 | * |
| 43 | * @param duration the measured inference duration. |
| 44 | * @param thresholdTime the threshold time in milliseconds. |
| 45 | * @return false if the measured time exceeded the threshold. |
| 46 | */ |
| 47 | bool CheckInferenceTimeThreshold(const std::chrono::duration<double, std::milli>& duration, |
| 48 | const double& thresholdTime) |
| 49 | { |
| 50 | ARMNN_LOG(info) << "\nInference time: " << std::setprecision(2) |
| 51 | << std::fixed << duration.count() << " ms\n"; |
| 52 | // If thresholdTime == 0.0 (default), then it hasn't been supplied at command line |
| 53 | if (thresholdTime != 0.0) |
| 54 | { |
| 55 | ARMNN_LOG(info) << "Threshold time: " << std::setprecision(2) |
| 56 | << std::fixed << thresholdTime << " ms"; |
| 57 | auto thresholdMinusInference = thresholdTime - duration.count(); |
| 58 | ARMNN_LOG(info) << "Threshold time - Inference time: " << std::setprecision(2) |
| 59 | << std::fixed << thresholdMinusInference << " ms" << "\n"; |
| 60 | if (thresholdMinusInference < 0) |
| 61 | { |
| 62 | std::string errorMessage = "Elapsed inference time is greater than provided threshold time."; |
| 63 | ARMNN_LOG(fatal) << errorMessage; |
| 64 | return false; |
| 65 | } |
| 66 | } |
| 67 | return true; |
| 68 | } |
| 69 | |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 70 | #if defined(ARMNN_TFLITE_DELEGATE) |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 71 | int TfLiteDelegateMainImpl(const ExecuteNetworkParams& params, const armnn::IRuntime::CreationOptions runtimeOptions, |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 72 | const std::shared_ptr<armnn::IRuntime>& runtime = nullptr) |
| 73 | { |
| 74 | using namespace tflite; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 75 | |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 76 | std::unique_ptr<tflite::FlatBufferModel> model = tflite::FlatBufferModel::BuildFromFile(params.m_ModelPath.c_str()); |
| 77 | |
| 78 | auto tfLiteInterpreter = std::make_unique<Interpreter>(); |
| 79 | tflite::ops::builtin::BuiltinOpResolver resolver; |
| 80 | |
| 81 | tflite::InterpreterBuilder builder(*model, resolver); |
| 82 | builder(&tfLiteInterpreter); |
| 83 | tfLiteInterpreter->AllocateTensors(); |
| 84 | |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 85 | int status = 0; |
| 86 | if (params.m_TfLiteExecutor == ExecuteNetworkParams::TfLiteExecutor::ArmNNTfLiteDelegate) |
Sadik Armagan | 19a1c03 | 2021-01-20 12:17:00 +0000 | [diff] [blame] | 87 | { |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 88 | // Create the Armnn Delegate |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 89 | // Populate a DelegateOptions from the ExecuteNetworkParams. |
| 90 | armnnDelegate::DelegateOptions delegateOptions = params.ToDelegateOptions(); |
| 91 | delegateOptions.SetExternalProfilingParams(runtimeOptions.m_ProfilingOptions); |
| 92 | |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 93 | std::unique_ptr<TfLiteDelegate, decltype(&armnnDelegate::TfLiteArmnnDelegateDelete)> |
| 94 | theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions), |
| 95 | armnnDelegate::TfLiteArmnnDelegateDelete); |
| 96 | // Register armnn_delegate to TfLiteInterpreter |
| 97 | status = tfLiteInterpreter->ModifyGraphWithDelegate(std::move(theArmnnDelegate)); |
| 98 | if (status == kTfLiteError) |
| 99 | { |
| 100 | ARMNN_LOG(fatal) << "Could not register ArmNN TfLite Delegate to TfLiteInterpreter!"; |
| 101 | return EXIT_FAILURE; |
| 102 | } |
Sadik Armagan | 19a1c03 | 2021-01-20 12:17:00 +0000 | [diff] [blame] | 103 | } |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 104 | else |
| 105 | { |
| 106 | std::cout << "Running on TfLite without ArmNN delegate\n"; |
| 107 | } |
| 108 | |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 109 | armnn::Optional<std::string> dataFile = params.m_GenerateTensorData |
| 110 | ? armnn::EmptyOptional() |
| 111 | : armnn::MakeOptional<std::string>(params.m_InputTensorDataFilePaths[0]); |
| 112 | |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 113 | const size_t numInputs = params.m_InputNames.size(); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 114 | |
| 115 | for(unsigned int inputIndex = 0; inputIndex < numInputs; ++inputIndex) |
| 116 | { |
| 117 | int input = tfLiteInterpreter->inputs()[inputIndex]; |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 118 | TfLiteIntArray* inputDims = tfLiteInterpreter->tensor(input)->dims; |
| 119 | |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 120 | unsigned int inputSize = 1; |
| 121 | if (params.m_InputTensorShapes.size() > 0) |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 122 | { |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 123 | inputSize = params.m_InputTensorShapes[inputIndex]->GetNumElements(); |
| 124 | } |
| 125 | else |
| 126 | { |
| 127 | for (unsigned int dim = 0; dim < static_cast<unsigned int>(inputDims->size); ++dim) |
| 128 | { |
| 129 | inputSize *= inputDims->data[dim]; |
| 130 | } |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 133 | if (params.m_InputTypes[inputIndex].compare("float") == 0) |
| 134 | { |
| 135 | auto inputData = tfLiteInterpreter->typed_tensor<float>(input); |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 136 | |
Matthew Sloyan | f00f6c2 | 2020-12-07 13:33:24 +0000 | [diff] [blame] | 137 | if(inputData == NULL) |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 138 | { |
| 139 | ARMNN_LOG(fatal) << "Input tensor is null, input type: " |
| 140 | "\"" << params.m_InputTypes[inputIndex] << "\" may be incorrect."; |
| 141 | return EXIT_FAILURE; |
| 142 | } |
| 143 | |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 144 | std::vector<float> tensorData; |
| 145 | PopulateTensorWithDataGeneric<float>(tensorData, |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 146 | inputSize, |
| 147 | dataFile, |
| 148 | [](const std::string& s) |
| 149 | { return std::stof(s); }); |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 150 | |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 151 | std::copy(tensorData.begin(), tensorData.end(), inputData); |
| 152 | } |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 153 | else if (params.m_InputTypes[inputIndex].compare("qsymms8") == 0) |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 154 | { |
| 155 | auto inputData = tfLiteInterpreter->typed_tensor<int8_t>(input); |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 156 | |
Matthew Sloyan | f00f6c2 | 2020-12-07 13:33:24 +0000 | [diff] [blame] | 157 | if(inputData == NULL) |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 158 | { |
| 159 | ARMNN_LOG(fatal) << "Input tensor is null, input type: " |
| 160 | "\"" << params.m_InputTypes[inputIndex] << "\" may be incorrect."; |
| 161 | return EXIT_FAILURE; |
| 162 | } |
| 163 | |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 164 | std::vector<int8_t> tensorData; |
| 165 | PopulateTensorWithDataGeneric<int8_t>(tensorData, |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 166 | inputSize, |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 167 | dataFile, |
| 168 | [](const std::string& s) |
| 169 | { return armnn::numeric_cast<int8_t>(std::stoi(s)); }); |
| 170 | |
| 171 | std::copy(tensorData.begin(), tensorData.end(), inputData); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 172 | } |
| 173 | else if (params.m_InputTypes[inputIndex].compare("int") == 0) |
| 174 | { |
| 175 | auto inputData = tfLiteInterpreter->typed_tensor<int32_t>(input); |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 176 | |
Matthew Sloyan | f00f6c2 | 2020-12-07 13:33:24 +0000 | [diff] [blame] | 177 | if(inputData == NULL) |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 178 | { |
| 179 | ARMNN_LOG(fatal) << "Input tensor is null, input type: " |
| 180 | "\"" << params.m_InputTypes[inputIndex] << "\" may be incorrect."; |
| 181 | return EXIT_FAILURE; |
| 182 | } |
| 183 | |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 184 | std::vector<int32_t> tensorData; |
| 185 | PopulateTensorWithDataGeneric<int32_t>(tensorData, |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 186 | inputSize, |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 187 | dataFile, |
| 188 | [](const std::string& s) |
| 189 | { return std::stoi(s); }); |
| 190 | |
| 191 | std::copy(tensorData.begin(), tensorData.end(), inputData); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 192 | } |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 193 | else if (params.m_InputTypes[inputIndex].compare("qasymm8") == 0 || |
| 194 | params.m_InputTypes[inputIndex].compare("qasymmu8") == 0) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 195 | { |
| 196 | auto inputData = tfLiteInterpreter->typed_tensor<uint8_t>(input); |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 197 | |
Matthew Sloyan | f00f6c2 | 2020-12-07 13:33:24 +0000 | [diff] [blame] | 198 | if(inputData == NULL) |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 199 | { |
| 200 | ARMNN_LOG(fatal) << "Input tensor is null, input type: " |
| 201 | "\"" << params.m_InputTypes[inputIndex] << "\" may be incorrect."; |
| 202 | return EXIT_FAILURE; |
| 203 | } |
| 204 | |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 205 | std::vector<uint8_t> tensorData; |
| 206 | PopulateTensorWithDataGeneric<uint8_t>(tensorData, |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 207 | inputSize, |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 208 | dataFile, |
| 209 | [](const std::string& s) |
| 210 | { return armnn::numeric_cast<uint8_t>(std::stoi(s)); }); |
| 211 | |
| 212 | std::copy(tensorData.begin(), tensorData.end(), inputData); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 213 | } |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 214 | else if (params.m_InputTypes[inputIndex].compare("qasymms8") == 0) |
| 215 | { |
| 216 | auto inputData = tfLiteInterpreter->typed_tensor<int8_t>(input); |
| 217 | |
| 218 | if(inputData == NULL) |
| 219 | { |
| 220 | ARMNN_LOG(fatal) << "Input tensor is null, input type: " |
| 221 | "\"" << params.m_InputTypes[inputIndex] << "\" may be incorrect."; |
| 222 | return EXIT_FAILURE; |
| 223 | } |
| 224 | |
| 225 | std::vector<int8_t> tensorData; |
| 226 | PopulateTensorWithDataGeneric<int8_t>(tensorData, |
Mike Kelly | 00e9ebf | 2021-09-01 17:09:12 +0100 | [diff] [blame] | 227 | inputSize, |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 228 | dataFile, |
| 229 | [](const std::string& s) |
| 230 | { return armnn::numeric_cast<int8_t>(std::stoi(s)); }); |
| 231 | |
| 232 | std::copy(tensorData.begin(), tensorData.end(), inputData); |
| 233 | } |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 234 | else |
| 235 | { |
| 236 | ARMNN_LOG(fatal) << "Unsupported input tensor data type \"" << params.m_InputTypes[inputIndex] << "\". "; |
| 237 | return EXIT_FAILURE; |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | for (size_t x = 0; x < params.m_Iterations; x++) |
| 242 | { |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 243 | // Start timer to record inference time in milliseconds. |
| 244 | const auto start_time = armnn::GetTimeNow(); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 245 | // Run the inference |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 246 | status = tfLiteInterpreter->Invoke(); |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 247 | const auto duration = armnn::GetTimeDuration(start_time); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 248 | |
| 249 | // Print out the output |
| 250 | for (unsigned int outputIndex = 0; outputIndex < params.m_OutputNames.size(); ++outputIndex) |
| 251 | { |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 252 | auto tfLiteDelegateOutputId = tfLiteInterpreter->outputs()[outputIndex]; |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 253 | TfLiteIntArray* outputDims = tfLiteInterpreter->tensor(tfLiteDelegateOutputId)->dims; |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 254 | // If we've been asked to write to a file then set a file output stream. Otherwise use stdout. |
| 255 | FILE* outputTensorFile = stdout; |
| 256 | if (!params.m_OutputTensorFiles.empty()) |
| 257 | { |
| 258 | outputTensorFile = fopen(params.m_OutputTensorFiles[outputIndex].c_str(), "w"); |
| 259 | if (outputTensorFile == NULL) |
| 260 | { |
| 261 | ARMNN_LOG(fatal) << "Specified output tensor file, \"" << |
| 262 | params.m_OutputTensorFiles[outputIndex] << |
| 263 | "\", cannot be created. Defaulting to stdout. " << |
| 264 | "Error was: " << std::strerror(errno); |
| 265 | outputTensorFile = stdout; |
| 266 | } |
| 267 | else |
| 268 | { |
| 269 | ARMNN_LOG(info) << "Writing output " << outputIndex << "' of iteration: " << x+1 << " to file: '" |
| 270 | << params.m_OutputTensorFiles[outputIndex] << "'"; |
| 271 | } |
| 272 | } |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 273 | long outputSize = 1; |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 274 | for (unsigned int dim = 0; dim < static_cast<unsigned int>(outputDims->size); ++dim) |
| 275 | { |
Sadik Armagan | 15f7fae | 2020-11-18 09:37:03 +0000 | [diff] [blame] | 276 | outputSize *= outputDims->data[dim]; |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | std::cout << params.m_OutputNames[outputIndex] << ": "; |
| 280 | if (params.m_OutputTypes[outputIndex].compare("float") == 0) |
| 281 | { |
| 282 | auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor<float>(tfLiteDelegateOutputId); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 283 | if(tfLiteDelageOutputData == NULL) |
| 284 | { |
| 285 | ARMNN_LOG(fatal) << "Output tensor is null, output type: " |
| 286 | "\"" << params.m_OutputTypes[outputIndex] << "\" may be incorrect."; |
| 287 | return EXIT_FAILURE; |
| 288 | } |
| 289 | |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 290 | if (!params.m_DontPrintOutputs) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 291 | { |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 292 | for (int i = 0; i < outputSize; ++i) |
| 293 | { |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 294 | fprintf(outputTensorFile, "%f ", tfLiteDelageOutputData[i]); |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 295 | } |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | else if (params.m_OutputTypes[outputIndex].compare("int") == 0) |
| 299 | { |
| 300 | auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor<int32_t>(tfLiteDelegateOutputId); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 301 | if(tfLiteDelageOutputData == NULL) |
| 302 | { |
| 303 | ARMNN_LOG(fatal) << "Output tensor is null, output type: " |
| 304 | "\"" << params.m_OutputTypes[outputIndex] << "\" may be incorrect."; |
| 305 | return EXIT_FAILURE; |
| 306 | } |
| 307 | |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 308 | if (!params.m_DontPrintOutputs) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 309 | { |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 310 | for (int i = 0; i < outputSize; ++i) |
| 311 | { |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 312 | fprintf(outputTensorFile, "%d ", tfLiteDelageOutputData[i]); |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 313 | } |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 314 | } |
| 315 | } |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 316 | else if (params.m_OutputTypes[outputIndex].compare("qsymms8") == 0) |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 317 | { |
| 318 | auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor<int8_t>(tfLiteDelegateOutputId); |
| 319 | if(tfLiteDelageOutputData == NULL) |
| 320 | { |
| 321 | ARMNN_LOG(fatal) << "Output tensor is null, output type: " |
| 322 | "\"" << params.m_OutputTypes[outputIndex] << "\" may be incorrect."; |
| 323 | return EXIT_FAILURE; |
| 324 | } |
| 325 | |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 326 | if (!params.m_DontPrintOutputs) |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 327 | { |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 328 | for (int i = 0; i < outputSize; ++i) |
| 329 | { |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 330 | fprintf(outputTensorFile, "%d ", tfLiteDelageOutputData[i]); |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 331 | } |
Finn Williams | 5687018 | 2020-11-20 13:57:53 +0000 | [diff] [blame] | 332 | } |
| 333 | } |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 334 | else if (params.m_OutputTypes[outputIndex].compare("qasymm8") == 0 || |
| 335 | params.m_OutputTypes[outputIndex].compare("qasymmu8") == 0) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 336 | { |
| 337 | auto tfLiteDelageOutputData = tfLiteInterpreter->typed_tensor<uint8_t>(tfLiteDelegateOutputId); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 338 | if(tfLiteDelageOutputData == NULL) |
| 339 | { |
| 340 | ARMNN_LOG(fatal) << "Output tensor is null, output type: " |
| 341 | "\"" << params.m_OutputTypes[outputIndex] << "\" may be incorrect."; |
| 342 | return EXIT_FAILURE; |
| 343 | } |
| 344 | |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 345 | if (!params.m_DontPrintOutputs) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 346 | { |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 347 | for (int i = 0; i < outputSize; ++i) |
| 348 | { |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 349 | fprintf(outputTensorFile, "%u ", tfLiteDelageOutputData[i]); |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 350 | } |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | else |
| 354 | { |
| 355 | ARMNN_LOG(fatal) << "Output tensor is null, output type: " |
| 356 | "\"" << params.m_OutputTypes[outputIndex] << |
| 357 | "\" may be incorrect. Output type can be specified with -z argument"; |
| 358 | return EXIT_FAILURE; |
| 359 | } |
| 360 | std::cout << std::endl; |
| 361 | } |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 362 | CheckInferenceTimeThreshold(duration, params.m_ThresholdTime); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | return status; |
| 366 | } |
| 367 | #endif |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 368 | template<typename TParser, typename TDataType> |
| 369 | int MainImpl(const ExecuteNetworkParams& params, |
| 370 | const std::shared_ptr<armnn::IRuntime>& runtime = nullptr) |
| 371 | { |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 372 | using namespace std::chrono; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 373 | |
David Monahan | 6bb47a7 | 2021-10-22 12:57:28 +0100 | [diff] [blame^] | 374 | std::vector<std::vector<armnn::TContainer>> inputs; |
| 375 | std::vector<std::vector<armnn::TContainer>> outputs; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 376 | |
| 377 | try |
| 378 | { |
| 379 | // Creates an InferenceModel, which will parse the model and load it into an IRuntime. |
| 380 | typename InferenceModel<TParser, TDataType>::Params inferenceModelParams; |
| 381 | inferenceModelParams.m_ModelPath = params.m_ModelPath; |
| 382 | inferenceModelParams.m_IsModelBinary = params.m_IsModelBinary; |
| 383 | inferenceModelParams.m_ComputeDevices = params.m_ComputeDevices; |
| 384 | inferenceModelParams.m_DynamicBackendsPath = params.m_DynamicBackendsPath; |
| 385 | inferenceModelParams.m_PrintIntermediateLayers = params.m_PrintIntermediate; |
| 386 | inferenceModelParams.m_VisualizePostOptimizationModel = params.m_EnableLayerDetails; |
| 387 | inferenceModelParams.m_ParseUnsupported = params.m_ParseUnsupported; |
| 388 | inferenceModelParams.m_InferOutputShape = params.m_InferOutputShape; |
| 389 | inferenceModelParams.m_EnableFastMath = params.m_EnableFastMath; |
Matthew Sloyan | 4243211 | 2021-01-08 10:30:51 +0000 | [diff] [blame] | 390 | inferenceModelParams.m_SaveCachedNetwork = params.m_SaveCachedNetwork; |
| 391 | inferenceModelParams.m_CachedNetworkFilePath = params.m_CachedNetworkFilePath; |
Matthew Sloyan | 0a7dc6b | 2021-02-10 16:50:53 +0000 | [diff] [blame] | 392 | inferenceModelParams.m_NumberOfThreads = params.m_NumberOfThreads; |
Finn Williams | 4064632 | 2021-02-11 16:16:42 +0000 | [diff] [blame] | 393 | inferenceModelParams.m_MLGOTuningFilePath = params.m_MLGOTuningFilePath; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 394 | inferenceModelParams.m_AsyncEnabled = params.m_Concurrent; |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 395 | inferenceModelParams.m_ThreadPoolSize = params.m_ThreadPoolSize; |
Keith Davis | f487486 | 2021-08-09 16:49:18 +0100 | [diff] [blame] | 396 | inferenceModelParams.m_OutputDetailsToStdOut = params.m_OutputDetailsToStdOut; |
Keith Davis | 4914d0c | 2021-08-18 17:14:05 +0100 | [diff] [blame] | 397 | inferenceModelParams.m_OutputDetailsOnlyToStdOut = params.m_OutputDetailsOnlyToStdOut; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 398 | |
| 399 | for(const std::string& inputName: params.m_InputNames) |
| 400 | { |
| 401 | inferenceModelParams.m_InputBindings.push_back(inputName); |
| 402 | } |
| 403 | |
| 404 | for(unsigned int i = 0; i < params.m_InputTensorShapes.size(); ++i) |
| 405 | { |
| 406 | inferenceModelParams.m_InputShapes.push_back(*params.m_InputTensorShapes[i]); |
| 407 | } |
| 408 | |
| 409 | for(const std::string& outputName: params.m_OutputNames) |
| 410 | { |
| 411 | inferenceModelParams.m_OutputBindings.push_back(outputName); |
| 412 | } |
| 413 | |
| 414 | inferenceModelParams.m_SubgraphId = params.m_SubgraphId; |
| 415 | inferenceModelParams.m_EnableFp16TurboMode = params.m_EnableFp16TurboMode; |
| 416 | inferenceModelParams.m_EnableBf16TurboMode = params.m_EnableBf16TurboMode; |
| 417 | |
| 418 | InferenceModel<TParser, TDataType> model(inferenceModelParams, |
| 419 | params.m_EnableProfiling, |
| 420 | params.m_DynamicBackendsPath, |
| 421 | runtime); |
| 422 | |
| 423 | const size_t numInputs = inferenceModelParams.m_InputBindings.size(); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 424 | |
| 425 | armnn::Optional<QuantizationParams> qParams = params.m_QuantizeInput ? |
| 426 | armnn::MakeOptional<QuantizationParams>( |
| 427 | model.GetInputQuantizationParams()) : |
| 428 | armnn::EmptyOptional(); |
| 429 | |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 430 | if (params.m_InputTensorDataFilePaths.size() > numInputs) |
| 431 | { |
| 432 | ARMNN_LOG(info) << "Given network has " << numInputs << " input/s. One input-tensor-data file is required " |
| 433 | << "for each input. The user provided " |
| 434 | << params.m_InputTensorDataFilePaths.size() |
| 435 | << " input-tensor-data file/s which will be used to fill the input/s.\n"; |
| 436 | } |
| 437 | |
| 438 | for(unsigned int j = 0; j < params.m_Iterations ; ++j) |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 439 | { |
David Monahan | 6bb47a7 | 2021-10-22 12:57:28 +0100 | [diff] [blame^] | 440 | std::vector<armnn::TContainer> inputDataContainers; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 441 | for(unsigned int i = 0; i < numInputs; ++i) |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 442 | { |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 443 | // If there are less input files given than required for the execution of |
| 444 | // params.m_Iterations we simply start with the first input file again |
| 445 | size_t inputFileIndex = j * numInputs + i; |
| 446 | if (!params.m_InputTensorDataFilePaths.empty()) |
| 447 | { |
| 448 | inputFileIndex = inputFileIndex % params.m_InputTensorDataFilePaths.size(); |
| 449 | } |
| 450 | |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 451 | armnn::Optional<std::string> dataFile = params.m_GenerateTensorData ? |
| 452 | armnn::EmptyOptional() : |
| 453 | armnn::MakeOptional<std::string>( |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 454 | params.m_InputTensorDataFilePaths.at(inputFileIndex)); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 455 | |
| 456 | unsigned int numElements = model.GetInputSize(i); |
| 457 | if (params.m_InputTensorShapes.size() > i && params.m_InputTensorShapes[i]) |
| 458 | { |
| 459 | // If the user has provided a tensor shape for the current input, |
| 460 | // override numElements |
| 461 | numElements = params.m_InputTensorShapes[i]->GetNumElements(); |
| 462 | } |
| 463 | |
David Monahan | 6bb47a7 | 2021-10-22 12:57:28 +0100 | [diff] [blame^] | 464 | armnn::TContainer tensorData; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 465 | PopulateTensorWithData(tensorData, |
| 466 | numElements, |
| 467 | params.m_InputTypes[i], |
| 468 | qParams, |
| 469 | dataFile); |
| 470 | |
| 471 | inputDataContainers.push_back(tensorData); |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 472 | } |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 473 | inputs.push_back(inputDataContainers); |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | const size_t numOutputs = inferenceModelParams.m_OutputBindings.size(); |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 477 | |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 478 | for (unsigned int j = 0; j < params.m_Iterations; ++j) |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 479 | { |
David Monahan | 6bb47a7 | 2021-10-22 12:57:28 +0100 | [diff] [blame^] | 480 | std::vector <armnn::TContainer> outputDataContainers; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 481 | for (unsigned int i = 0; i < numOutputs; ++i) |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 482 | { |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 483 | if (params.m_OutputTypes[i].compare("float") == 0) |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 484 | { |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 485 | outputDataContainers.push_back(std::vector<float>(model.GetOutputSize(i))); |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 486 | } |
| 487 | else if (params.m_OutputTypes[i].compare("int") == 0) |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 488 | { |
| 489 | outputDataContainers.push_back(std::vector<int>(model.GetOutputSize(i))); |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 490 | } |
| 491 | else if (params.m_OutputTypes[i].compare("qasymm8") == 0 || |
| 492 | params.m_OutputTypes[i].compare("qasymmu8") == 0) |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 493 | { |
| 494 | outputDataContainers.push_back(std::vector<uint8_t>(model.GetOutputSize(i))); |
Mike Kelly | d7ed6d4 | 2021-07-21 09:42:43 +0100 | [diff] [blame] | 495 | } |
| 496 | else if (params.m_OutputTypes[i].compare("qasymms8") == 0) |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 497 | { |
| 498 | outputDataContainers.push_back(std::vector<int8_t>(model.GetOutputSize(i))); |
| 499 | } else |
| 500 | { |
| 501 | ARMNN_LOG(fatal) << "Unsupported tensor data type \"" << params.m_OutputTypes[i] << "\". "; |
| 502 | return EXIT_FAILURE; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 503 | } |
| 504 | } |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 505 | outputs.push_back(outputDataContainers); |
| 506 | } |
| 507 | |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 508 | if (params.m_Iterations > 1) |
| 509 | { |
| 510 | std::stringstream msg; |
| 511 | msg << "Network will be executed " << params.m_Iterations; |
| 512 | if (params.m_Concurrent) |
| 513 | { |
| 514 | msg << " times in an asynchronous manner. "; |
| 515 | } |
| 516 | else |
| 517 | { |
| 518 | msg << " times successively. "; |
| 519 | } |
| 520 | msg << "The input-tensor-data files will be reused recursively if the user didn't provide enough to " |
| 521 | "cover each execution."; |
| 522 | ARMNN_LOG(info) << msg.str(); |
| 523 | } |
| 524 | |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 525 | // Synchronous execution |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 526 | if (!params.m_Concurrent) |
| 527 | { |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 528 | for (size_t x = 0; x < params.m_Iterations; x++) |
| 529 | { |
| 530 | // model.Run returns the inference time elapsed in EnqueueWorkload (in milliseconds) |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 531 | auto inference_duration = model.Run(inputs[x], outputs[x]); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 532 | |
| 533 | if (params.m_GenerateTensorData) |
| 534 | { |
| 535 | ARMNN_LOG(warning) << "The input data was generated, note that the output will not be useful"; |
| 536 | } |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 537 | if (params.m_DontPrintOutputs) |
| 538 | { |
| 539 | ARMNN_LOG(info) << "Printing outputs to console is disabled."; |
| 540 | } |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 541 | |
| 542 | // Print output tensors |
| 543 | const auto& infosOut = model.GetOutputBindingInfos(); |
| 544 | for (size_t i = 0; i < numOutputs; i++) |
| 545 | { |
| 546 | const armnn::TensorInfo& infoOut = infosOut[i].second; |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 547 | |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 548 | // We've made sure before that the number of output files either equals numOutputs, in which |
| 549 | // case we override those files when processing the results of each iteration (only the result |
| 550 | // of the last iteration will be stored), or there are enough |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 551 | // output files for each output of each iteration. |
| 552 | size_t outputFileIndex = x * numOutputs + i; |
| 553 | if (!params.m_OutputTensorFiles.empty()) |
| 554 | { |
| 555 | outputFileIndex = outputFileIndex % params.m_OutputTensorFiles.size(); |
| 556 | ARMNN_LOG(info) << "Writing output " << i << " named: '" |
| 557 | << inferenceModelParams.m_OutputBindings[i] |
| 558 | << "' of iteration: " << x+1 << " to file: '" |
| 559 | << params.m_OutputTensorFiles[outputFileIndex] << "'"; |
| 560 | } |
| 561 | auto outputTensorFile = params.m_OutputTensorFiles.empty() |
| 562 | ? "" |
| 563 | : params.m_OutputTensorFiles[outputFileIndex]; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 564 | |
| 565 | TensorPrinter printer(inferenceModelParams.m_OutputBindings[i], |
| 566 | infoOut, |
| 567 | outputTensorFile, |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 568 | params.m_DequantizeOutput, |
| 569 | !params.m_DontPrintOutputs); |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 570 | mapbox::util::apply_visitor(printer, outputs[x][i]); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | ARMNN_LOG(info) << "\nInference time: " << std::setprecision(2) |
| 574 | << std::fixed << inference_duration.count() << " ms\n"; |
| 575 | |
| 576 | // If thresholdTime == 0.0 (default), then it hasn't been supplied at command line |
| 577 | if (params.m_ThresholdTime != 0.0) |
| 578 | { |
| 579 | ARMNN_LOG(info) << "Threshold time: " << std::setprecision(2) |
| 580 | << std::fixed << params.m_ThresholdTime << " ms"; |
| 581 | auto thresholdMinusInference = params.m_ThresholdTime - inference_duration.count(); |
| 582 | ARMNN_LOG(info) << "Threshold time - Inference time: " << std::setprecision(2) |
| 583 | << std::fixed << thresholdMinusInference << " ms" << "\n"; |
| 584 | |
| 585 | if (thresholdMinusInference < 0) |
| 586 | { |
| 587 | std::string errorMessage = "Elapsed inference time is greater than provided threshold time."; |
| 588 | ARMNN_LOG(fatal) << errorMessage; |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | } |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 593 | // Asynchronous execution using the Arm NN thread pool |
Kevin May | 94dd4db | 2021-05-26 16:01:08 +0100 | [diff] [blame] | 594 | else if (params.m_ThreadPoolSize >= 1) |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 595 | { |
| 596 | try |
| 597 | { |
| 598 | ARMNN_LOG(info) << "Asynchronous execution with Arm NN thread pool... \n"; |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 599 | armnn::AsyncCallbackManager callbackManager; |
David Monahan | 6bb47a7 | 2021-10-22 12:57:28 +0100 | [diff] [blame^] | 600 | std::unordered_map<armnn::InferenceId, std::vector<armnn::TContainer>&> inferenceOutputMap; |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 601 | |
| 602 | // Declare the latest and earliest inference times here to be used when calculating overall time |
| 603 | std::chrono::high_resolution_clock::time_point earliestStartTime; |
| 604 | std::chrono::high_resolution_clock::time_point latestEndTime = |
| 605 | std::chrono::high_resolution_clock::now(); |
| 606 | |
| 607 | // For the asynchronous execution, we are adding a pool of working memory handles (1 per thread) in the |
| 608 | // LoadedNetwork with each scheduled inference having a specific priority |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 609 | for (size_t i = 0; i < params.m_Iterations; ++i) |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 610 | { |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 611 | std::shared_ptr<armnn::AsyncExecutionCallback> cb = callbackManager.GetNewCallback(); |
| 612 | inferenceOutputMap.insert({cb->GetInferenceId(), outputs[i]}); |
| 613 | model.RunAsync(inputs[i], outputs[i], cb); |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | // Check the results |
| 617 | unsigned int j = 0; |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 618 | for (size_t iteration = 0; iteration < params.m_Iterations; ++iteration) |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 619 | { |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 620 | auto cb = callbackManager.GetNotifiedCallback(); |
| 621 | |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 622 | // Get the results |
| 623 | auto endTime = time_point_cast<std::chrono::milliseconds>(cb->GetEndTime()); |
| 624 | auto startTime = time_point_cast<std::chrono::milliseconds>(cb->GetStartTime()); |
| 625 | auto inferenceDuration = endTime - startTime; |
| 626 | |
| 627 | if (latestEndTime < cb->GetEndTime()) |
| 628 | { |
| 629 | latestEndTime = cb->GetEndTime(); |
| 630 | } |
| 631 | |
| 632 | if (earliestStartTime.time_since_epoch().count() == 0) |
| 633 | { |
| 634 | earliestStartTime = cb->GetStartTime(); |
| 635 | } |
| 636 | else if (earliestStartTime > cb->GetStartTime()) |
| 637 | { |
| 638 | earliestStartTime = cb->GetStartTime(); |
| 639 | } |
| 640 | |
| 641 | if (params.m_GenerateTensorData) |
| 642 | { |
| 643 | ARMNN_LOG(warning) << "The input data was generated, note that the output will not be useful"; |
| 644 | } |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 645 | if (params.m_DontPrintOutputs) |
| 646 | { |
| 647 | ARMNN_LOG(info) << "Printing outputs to console is disabled."; |
| 648 | } |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 649 | |
| 650 | // Print output tensors |
| 651 | const auto& infosOut = model.GetOutputBindingInfos(); |
| 652 | for (size_t i = 0; i < numOutputs; i++) |
| 653 | { |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 654 | // We've made sure before that the number of output files either equals numOutputs, in which |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 655 | // case we override those files when processing the results of each iteration (only the |
| 656 | // result of the last iteration will be stored), or there are enough |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 657 | // output files for each output of each iteration. |
| 658 | size_t outputFileIndex = iteration * numOutputs + i; |
| 659 | if (!params.m_OutputTensorFiles.empty()) |
| 660 | { |
| 661 | outputFileIndex = outputFileIndex % params.m_OutputTensorFiles.size(); |
| 662 | ARMNN_LOG(info) << "Writing output " << i << " named: '" |
| 663 | << inferenceModelParams.m_OutputBindings[i] |
| 664 | << "' of iteration: " << iteration+1 << " to file: '" |
| 665 | << params.m_OutputTensorFiles[outputFileIndex] << "'"; |
| 666 | } |
| 667 | |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 668 | const armnn::TensorInfo& infoOut = infosOut[i].second; |
| 669 | auto outputTensorFile = params.m_OutputTensorFiles.empty() |
| 670 | ? "" |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 671 | : params.m_OutputTensorFiles[outputFileIndex]; |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 672 | |
| 673 | TensorPrinter printer(inferenceModelParams.m_OutputBindings[i], |
| 674 | infoOut, |
| 675 | outputTensorFile, |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 676 | params.m_DequantizeOutput, |
| 677 | !params.m_DontPrintOutputs); |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 678 | mapbox::util::apply_visitor(printer, inferenceOutputMap.at(cb->GetInferenceId())[i]); |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 679 | } |
| 680 | |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 681 | CheckInferenceTimeThreshold(inferenceDuration, params.m_ThresholdTime); |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 682 | ++j; |
| 683 | } |
| 684 | //print duration difference between overallStartTime and overallEndTime |
| 685 | auto overallEndTime = time_point_cast<std::chrono::milliseconds>(latestEndTime); |
| 686 | auto overallStartTime = time_point_cast<std::chrono::milliseconds>(earliestStartTime); |
| 687 | auto totalInferenceDuration = overallEndTime - overallStartTime; |
| 688 | ARMNN_LOG(info) << "\nOverall Inference time: " << std::setprecision(2) |
| 689 | << std::fixed << totalInferenceDuration.count() << " ms\n"; |
| 690 | } |
| 691 | catch (const armnn::Exception& e) |
| 692 | { |
| 693 | ARMNN_LOG(fatal) << "Armnn Error: " << e.what(); |
| 694 | return EXIT_FAILURE; |
| 695 | } |
| 696 | } |
| 697 | // Asynchronous execution using std::launch::async |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 698 | else |
| 699 | { |
| 700 | try |
| 701 | { |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 702 | ARMNN_LOG(info) << "Asynchronous Execution with std::launch:async... \n"; |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 703 | std::vector<std::future<std::tuple<unsigned int, |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 704 | std::chrono::duration<double, std::milli>>>> inferenceResults; |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 705 | inferenceResults.reserve(params.m_Iterations); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 706 | |
| 707 | // Create WorkingMemHandles for each inference |
| 708 | std::vector<std::unique_ptr<armnn::experimental::IWorkingMemHandle>> workingMemHandles; |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 709 | workingMemHandles.reserve(params.m_Iterations); |
| 710 | for (unsigned int i = 0; i < params.m_Iterations; ++i) |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 711 | { |
| 712 | workingMemHandles.push_back(model.CreateWorkingMemHandle()); |
| 713 | } |
| 714 | |
| 715 | // Run each inference in its own thread |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 716 | // start a timer |
| 717 | const auto start_time = armnn::GetTimeNow(); |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 718 | for (unsigned int i = 0; i < params.m_Iterations; ++i) |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 719 | { |
| 720 | armnn::experimental::IWorkingMemHandle& workingMemHandleRef = *workingMemHandles[i].get(); |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 721 | |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 722 | inferenceResults.push_back(std::async( |
| 723 | std::launch::async, [&model, &workingMemHandleRef, &inputs, &outputs, i]() { |
Finn Williams | f364d53 | 2021-06-09 17:07:33 +0100 | [diff] [blame] | 724 | return model.RunAsync(workingMemHandleRef, inputs[i], outputs[i], i); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 725 | } |
| 726 | )); |
| 727 | } |
| 728 | |
| 729 | // Check the results |
| 730 | for (unsigned int j = 0; j < inferenceResults.size(); ++j) |
| 731 | { |
| 732 | // Get the results |
| 733 | auto inferenceResult = inferenceResults[j].get(); |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 734 | auto inferenceDuration = std::get<1>(inferenceResult); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 735 | auto inferenceID = std::get<0>(inferenceResult); |
| 736 | |
| 737 | if (params.m_GenerateTensorData) |
| 738 | { |
| 739 | ARMNN_LOG(warning) << "The input data was generated, note that the output will not be useful"; |
| 740 | } |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 741 | if (params.m_DontPrintOutputs) |
| 742 | { |
| 743 | ARMNN_LOG(info) << "Printing outputs to console is disabled."; |
| 744 | } |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 745 | |
| 746 | // Print output tensors |
| 747 | const auto& infosOut = model.GetOutputBindingInfos(); |
| 748 | for (size_t i = 0; i < numOutputs; i++) |
| 749 | { |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 750 | // We've made sure before that the number of output files either equals numOutputs, in which |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 751 | // case we override those files when processing the results of each iteration (only the |
| 752 | // result of the last iteration will be stored), or there are enough |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 753 | // output files for each output of each iteration. |
| 754 | size_t outputFileIndex = j * numOutputs + i; |
| 755 | if (!params.m_OutputTensorFiles.empty()) |
| 756 | { |
| 757 | outputFileIndex = outputFileIndex % params.m_OutputTensorFiles.size(); |
| 758 | ARMNN_LOG(info) << "Writing output " << i << " named: '" |
| 759 | << inferenceModelParams.m_OutputBindings[i] |
| 760 | << "' of iteration: " << j+1 << " to file: '" |
| 761 | << params.m_OutputTensorFiles[outputFileIndex] << "'"; |
| 762 | } |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 763 | const armnn::TensorInfo& infoOut = infosOut[i].second; |
| 764 | auto outputTensorFile = params.m_OutputTensorFiles.empty() |
| 765 | ? "" |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 766 | : params.m_OutputTensorFiles[outputFileIndex]; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 767 | |
| 768 | TensorPrinter printer(inferenceModelParams.m_OutputBindings[i], |
| 769 | infoOut, |
| 770 | outputTensorFile, |
Jan Eilers | 284b5d1 | 2021-09-07 12:46:15 +0100 | [diff] [blame] | 771 | params.m_DequantizeOutput, |
| 772 | !params.m_DontPrintOutputs); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 773 | mapbox::util::apply_visitor(printer, outputs[j][i]); |
| 774 | } |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 775 | CheckInferenceTimeThreshold(inferenceDuration, params.m_ThresholdTime); |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 776 | ARMNN_LOG(info) << "Asynchronous Execution is finished for Inference ID: " << inferenceID << " \n"; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 777 | } |
Kevin May | b4b3ac9 | 2021-05-21 16:42:21 +0100 | [diff] [blame] | 778 | // finish timer |
| 779 | const auto duration = armnn::GetTimeDuration(start_time); |
| 780 | ARMNN_LOG(info) << "\nOverall Inference time: " << std::setprecision(2) |
| 781 | << std::fixed << duration.count() << " ms\n"; |
Sadik Armagan | a04a9d7 | 2021-04-27 10:02:10 +0100 | [diff] [blame] | 782 | } |
| 783 | catch (const armnn::Exception& e) |
| 784 | { |
| 785 | ARMNN_LOG(fatal) << "Armnn Error: " << e.what(); |
| 786 | return EXIT_FAILURE; |
| 787 | } |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 788 | } |
| 789 | } |
| 790 | catch (const armnn::Exception& e) |
| 791 | { |
| 792 | ARMNN_LOG(fatal) << "Armnn Error: " << e.what(); |
| 793 | return EXIT_FAILURE; |
| 794 | } |
| 795 | |
| 796 | return EXIT_SUCCESS; |
| 797 | } |
| 798 | |
James Conroy | 7b4886f | 2019-04-11 10:23:58 +0100 | [diff] [blame] | 799 | // MAIN |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 800 | int main(int argc, const char* argv[]) |
| 801 | { |
| 802 | // Configures logging for both the ARMNN library and this test program. |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 803 | #ifdef NDEBUG |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 804 | armnn::LogSeverity level = armnn::LogSeverity::Info; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 805 | #else |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 806 | armnn::LogSeverity level = armnn::LogSeverity::Debug; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 807 | #endif |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 808 | armnn::ConfigureLogging(true, true, level); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 809 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 810 | |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 811 | // Get ExecuteNetwork parameters and runtime options from command line |
Jan Eilers | f17fcd5 | 2021-07-26 22:20:00 +0100 | [diff] [blame] | 812 | // This might throw an InvalidArgumentException if the user provided invalid inputs |
| 813 | ProgramOptions ProgramOptions; |
| 814 | try { |
| 815 | ProgramOptions.ParseOptions(argc, argv); |
| 816 | } catch (const std::exception &e){ |
| 817 | ARMNN_LOG(fatal) << e.what(); |
| 818 | return EXIT_FAILURE; |
| 819 | } |
Narumol Prangnawarat | d8cc811 | 2020-03-24 13:54:05 +0000 | [diff] [blame] | 820 | |
Keith Davis | 4914d0c | 2021-08-18 17:14:05 +0100 | [diff] [blame] | 821 | if ((ProgramOptions.m_ExNetParams.m_OutputDetailsToStdOut || |
| 822 | ProgramOptions.m_ExNetParams.m_OutputDetailsOnlyToStdOut) |
| 823 | && !ProgramOptions.m_ExNetParams.m_EnableProfiling) |
Keith Davis | f487486 | 2021-08-09 16:49:18 +0100 | [diff] [blame] | 824 | { |
| 825 | ARMNN_LOG(fatal) << "You must enable profiling if you would like to output layer details"; |
| 826 | return EXIT_FAILURE; |
| 827 | } |
| 828 | |
Finn Williams | d7fcafa | 2020-04-23 17:55:18 +0100 | [diff] [blame] | 829 | // Create runtime |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 830 | std::shared_ptr<armnn::IRuntime> runtime(armnn::IRuntime::Create(ProgramOptions.m_RuntimeOptions)); |
Finn Williams | d7fcafa | 2020-04-23 17:55:18 +0100 | [diff] [blame] | 831 | |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 832 | std::string modelFormat = ProgramOptions.m_ExNetParams.m_ModelFormat; |
| 833 | |
| 834 | // Forward to implementation based on the parser type |
| 835 | if (modelFormat.find("armnn") != std::string::npos) |
Finn Williams | d7fcafa | 2020-04-23 17:55:18 +0100 | [diff] [blame] | 836 | { |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 837 | #if defined(ARMNN_SERIALIZER) |
| 838 | return MainImpl<armnnDeserializer::IDeserializer, float>(ProgramOptions.m_ExNetParams, runtime); |
| 839 | #else |
| 840 | ARMNN_LOG(fatal) << "Not built with serialization support."; |
Finn Williams | d7fcafa | 2020-04-23 17:55:18 +0100 | [diff] [blame] | 841 | return EXIT_FAILURE; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 842 | #endif |
Finn Williams | d7fcafa | 2020-04-23 17:55:18 +0100 | [diff] [blame] | 843 | } |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 844 | else if (modelFormat.find("onnx") != std::string::npos) |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 845 | { |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 846 | #if defined(ARMNN_ONNX_PARSER) |
| 847 | return MainImpl<armnnOnnxParser::IOnnxParser, float>(ProgramOptions.m_ExNetParams, runtime); |
| 848 | #else |
| 849 | ARMNN_LOG(fatal) << "Not built with Onnx parser support."; |
| 850 | return EXIT_FAILURE; |
| 851 | #endif |
| 852 | } |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 853 | else if(modelFormat.find("tflite") != std::string::npos) |
| 854 | { |
Finn Williams | f806c4d | 2021-02-22 15:13:12 +0000 | [diff] [blame] | 855 | if (ProgramOptions.m_ExNetParams.m_TfLiteExecutor == ExecuteNetworkParams::TfLiteExecutor::ArmNNTfLiteParser) |
| 856 | { |
| 857 | #if defined(ARMNN_TF_LITE_PARSER) |
| 858 | return MainImpl<armnnTfLiteParser::ITfLiteParser, float>(ProgramOptions.m_ExNetParams, runtime); |
| 859 | #else |
| 860 | ARMNN_LOG(fatal) << "Not built with Tensorflow-Lite parser support."; |
| 861 | return EXIT_FAILURE; |
| 862 | #endif |
| 863 | } |
| 864 | else if (ProgramOptions.m_ExNetParams.m_TfLiteExecutor == |
| 865 | ExecuteNetworkParams::TfLiteExecutor::ArmNNTfLiteDelegate || |
| 866 | ProgramOptions.m_ExNetParams.m_TfLiteExecutor == |
| 867 | ExecuteNetworkParams::TfLiteExecutor::TfliteInterpreter) |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 868 | { |
| 869 | #if defined(ARMNN_TF_LITE_DELEGATE) |
Colm Donelan | 3cff15a | 2021-10-12 15:06:19 +0100 | [diff] [blame] | 870 | return TfLiteDelegateMainImpl(ProgramOptions.m_ExNetParams, ProgramOptions.m_RuntimeOptions, runtime); |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 871 | #else |
Finn Williams | bbbefec | 2020-11-25 14:32:42 +0000 | [diff] [blame] | 872 | ARMNN_LOG(fatal) << "Not built with Arm NN Tensorflow-Lite delegate support."; |
Sadik Armagan | 5d03e31 | 2020-11-17 16:43:56 +0000 | [diff] [blame] | 873 | return EXIT_FAILURE; |
| 874 | #endif |
| 875 | } |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 876 | } |
| 877 | else |
| 878 | { |
| 879 | ARMNN_LOG(fatal) << "Unknown model format: '" << modelFormat |
Nikhil Raj | 5d955cf | 2021-04-19 16:59:48 +0100 | [diff] [blame] | 880 | << "'. Please include 'tflite' or 'onnx'"; |
Jan Eilers | 4527490 | 2020-10-15 18:34:43 +0100 | [diff] [blame] | 881 | return EXIT_FAILURE; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 882 | } |
| 883 | } |