351 #if (!defined(ARMNN_CAFFE_PARSER) \ 352 && !defined(ARMNN_ONNX_PARSER) \ 353 && !defined(ARMNN_TF_PARSER) \ 354 && !defined(ARMNN_TF_LITE_PARSER)) 355 ARMNN_LOG(fatal) <<
"Not built with any of the supported parsers, Caffe, Onnx, Tensorflow, or TfLite.";
359 #if !defined(ARMNN_SERIALIZER) 360 ARMNN_LOG(fatal) <<
"Not built with Serializer support.";
372 std::string modelFormat;
373 std::string modelPath;
375 std::vector<std::string> inputNames;
376 std::vector<std::string> inputTensorShapeStrs;
377 std::vector<armnn::TensorShape> inputTensorShapes;
379 std::vector<std::string> outputNames;
380 std::string outputPath;
382 bool isModelBinary =
true;
384 if (ParseCommandLineArgs(
385 argc, argv, modelFormat, modelPath, inputNames, inputTensorShapeStrs, outputNames, outputPath, isModelBinary)
391 for (
const std::string& shapeStr : inputTensorShapeStrs)
393 if (!shapeStr.empty())
395 std::stringstream ss(shapeStr);
400 inputTensorShapes.push_back(shape);
404 ARMNN_LOG(fatal) <<
"Cannot create tensor shape: " << e.
what();
410 ArmnnConverter converter(modelPath, inputNames, inputTensorShapes, outputNames, outputPath, isModelBinary);
414 if (modelFormat.find(
"caffe") != std::string::npos)
416 #if defined(ARMNN_CAFFE_PARSER) 419 ARMNN_LOG(fatal) <<
"Failed to load model from file";
423 ARMNN_LOG(fatal) <<
"Not built with Caffe parser support.";
427 else if (modelFormat.find(
"onnx") != std::string::npos)
429 #if defined(ARMNN_ONNX_PARSER) 432 ARMNN_LOG(fatal) <<
"Failed to load model from file";
436 ARMNN_LOG(fatal) <<
"Not built with Onnx parser support.";
440 else if (modelFormat.find(
"tensorflow") != std::string::npos)
442 #if defined(ARMNN_TF_PARSER) 445 ARMNN_LOG(fatal) <<
"Failed to load model from file";
449 ARMNN_LOG(fatal) <<
"Not built with Tensorflow parser support.";
453 else if (modelFormat.find(
"tflite") != std::string::npos)
455 #if defined(ARMNN_TF_LITE_PARSER) 458 ARMNN_LOG(fatal) <<
"Unknown model format: '" << modelFormat <<
"'. Only 'binary' format supported \ 465 ARMNN_LOG(fatal) <<
"Failed to load model from file";
469 ARMNN_LOG(fatal) <<
"Not built with TfLite parser support.";
475 ARMNN_LOG(fatal) <<
"Unknown model format: '" << modelFormat <<
"'";
481 ARMNN_LOG(fatal) <<
"Failed to load model from file: " << e.
what();
485 if (!converter.Serialize())
487 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.