339 #if (!defined(ARMNN_CAFFE_PARSER) \ 340 && !defined(ARMNN_ONNX_PARSER) \ 341 && !defined(ARMNN_TF_PARSER) \ 342 && !defined(ARMNN_TF_LITE_PARSER)) 343 ARMNN_LOG(fatal) <<
"Not built with any of the supported parsers, Caffe, Onnx, Tensorflow, or TfLite.";
347 #if !defined(ARMNN_SERIALIZER) 348 ARMNN_LOG(fatal) <<
"Not built with Serializer support.";
360 std::string modelFormat;
361 std::string modelPath;
363 std::vector<std::string> inputNames;
364 std::vector<std::string> inputTensorShapeStrs;
365 std::vector<armnn::TensorShape> inputTensorShapes;
367 std::vector<std::string> outputNames;
368 std::string outputPath;
370 bool isModelBinary =
true;
372 if (ParseCommandLineArgs(
373 argc, argv, modelFormat, modelPath, inputNames, inputTensorShapeStrs, outputNames, outputPath, isModelBinary)
379 for (
const std::string& shapeStr : inputTensorShapeStrs)
381 if (!shapeStr.empty())
383 std::stringstream ss(shapeStr);
388 inputTensorShapes.push_back(shape);
392 ARMNN_LOG(fatal) <<
"Cannot create tensor shape: " << e.
what();
398 ArmnnConverter converter(modelPath, inputNames, inputTensorShapes, outputNames, outputPath, isModelBinary);
402 if (modelFormat.find(
"caffe") != std::string::npos)
404 #if defined(ARMNN_CAFFE_PARSER) 407 ARMNN_LOG(fatal) <<
"Failed to load model from file";
411 ARMNN_LOG(fatal) <<
"Not built with Caffe parser support.";
415 else if (modelFormat.find(
"onnx") != std::string::npos)
417 #if defined(ARMNN_ONNX_PARSER) 420 ARMNN_LOG(fatal) <<
"Failed to load model from file";
424 ARMNN_LOG(fatal) <<
"Not built with Onnx parser support.";
428 else if (modelFormat.find(
"tensorflow") != std::string::npos)
430 #if defined(ARMNN_TF_PARSER) 433 ARMNN_LOG(fatal) <<
"Failed to load model from file";
437 ARMNN_LOG(fatal) <<
"Not built with Tensorflow parser support.";
441 else if (modelFormat.find(
"tflite") != std::string::npos)
443 #if defined(ARMNN_TF_LITE_PARSER) 446 ARMNN_LOG(fatal) <<
"Unknown model format: '" << modelFormat <<
"'. Only 'binary' format supported \ 453 ARMNN_LOG(fatal) <<
"Failed to load model from file";
457 ARMNN_LOG(fatal) <<
"Not built with TfLite parser support.";
463 ARMNN_LOG(fatal) <<
"Unknown model format: '" << modelFormat <<
"'";
469 ARMNN_LOG(fatal) <<
"Failed to load model from file: " << e.
what();
473 if (!converter.Serialize())
475 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.