362 #if (!defined(ARMNN_CAFFE_PARSER) \ 363 && !defined(ARMNN_ONNX_PARSER) \ 364 && !defined(ARMNN_TF_PARSER) \ 365 && !defined(ARMNN_TF_LITE_PARSER)) 366 ARMNN_LOG(fatal) <<
"Not built with any of the supported parsers, Caffe, Onnx, Tensorflow, or TfLite.";
370 #if !defined(ARMNN_SERIALIZER) 371 ARMNN_LOG(fatal) <<
"Not built with Serializer support.";
383 std::string modelFormat;
384 std::string modelPath;
386 std::vector<std::string> inputNames;
387 std::vector<std::string> inputTensorShapeStrs;
388 std::vector<armnn::TensorShape> inputTensorShapes;
390 std::vector<std::string> outputNames;
391 std::string outputPath;
393 bool isModelBinary =
true;
395 if (ParseCommandLineArgs(
396 argc, argv, modelFormat, modelPath, inputNames, inputTensorShapeStrs, outputNames, outputPath, isModelBinary)
402 for (
const std::string& shapeStr : inputTensorShapeStrs)
404 if (!shapeStr.empty())
406 std::stringstream ss(shapeStr);
411 inputTensorShapes.push_back(shape);
415 ARMNN_LOG(fatal) <<
"Cannot create tensor shape: " << e.
what();
421 ArmnnConverter converter(modelPath, inputNames, inputTensorShapes, outputNames, outputPath, isModelBinary);
425 if (modelFormat.find(
"caffe") != std::string::npos)
427 #if defined(ARMNN_CAFFE_PARSER) 430 ARMNN_LOG(fatal) <<
"Failed to load model from file";
434 ARMNN_LOG(fatal) <<
"Not built with Caffe parser support.";
438 else if (modelFormat.find(
"onnx") != std::string::npos)
440 #if defined(ARMNN_ONNX_PARSER) 443 ARMNN_LOG(fatal) <<
"Failed to load model from file";
447 ARMNN_LOG(fatal) <<
"Not built with Onnx parser support.";
451 else if (modelFormat.find(
"tensorflow") != std::string::npos)
453 #if defined(ARMNN_TF_PARSER) 456 ARMNN_LOG(fatal) <<
"Failed to load model from file";
460 ARMNN_LOG(fatal) <<
"Not built with Tensorflow parser support.";
464 else if (modelFormat.find(
"tflite") != std::string::npos)
466 #if defined(ARMNN_TF_LITE_PARSER) 469 ARMNN_LOG(fatal) <<
"Unknown model format: '" << modelFormat <<
"'. Only 'binary' format supported \ 476 ARMNN_LOG(fatal) <<
"Failed to load model from file";
480 ARMNN_LOG(fatal) <<
"Not built with TfLite parser support.";
486 ARMNN_LOG(fatal) <<
"Unknown model format: '" << modelFormat <<
"'";
492 ARMNN_LOG(fatal) <<
"Failed to load model from file: " << e.
what();
496 if (!converter.Serialize())
498 ARMNN_LOG(fatal) <<
"Failed to serialize model";
void ConfigureLogging(bool printToStandardOutput, bool printToDebugOutput, LogSeverity severity)
Configures the logging behaviour of the ARMNN library.
virtual const char * what() const noexcept override
#define ARMNN_LOG(severity)
Parses a directed acyclic graph from a tensorflow protobuf file.
Base class for all ArmNN exceptions so that users can filter to just those.