From 6ba9f4f23597082243acf91a2039465125acf940 Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Fri, 8 Sep 2023 10:59:16 +0200 Subject: [PATCH] conditional build for tflite in cli --- cli/src/dump.rs | 6 ++++++ cli/src/params.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/cli/src/dump.rs b/cli/src/dump.rs index 4756e4ec42..6309d45b1f 100644 --- a/cli/src/dump.rs +++ b/cli/src/dump.rs @@ -220,6 +220,7 @@ pub fn handle( } } + #[cfg(feature = "tflite")] if let Some(path) = sub_matches.value_of("tflite") { let tflite = tract_tflite::tflite(); if let Some(mut typed) = model.downcast_ref::().cloned() { @@ -232,6 +233,11 @@ pub fn handle( } } + #[cfg(not(feature = "tflite"))] + if sub_matches.value_of("tflite").is_some() { + bail!("This is a tract build without support for tflite.") + } + if options.cost { let total = annotations.tags.values().sum::(); let assert = diff --git a/cli/src/params.rs b/cli/src/params.rs index 149658da0b..37563bab7c 100644 --- a/cli/src/params.rs +++ b/cli/src/params.rs @@ -733,6 +733,7 @@ impl Parameters { }); stage!("nnef-declutter", typed_model -> typed_model, |m:TypedModel| m.into_decluttered()); } + #[cfg(feature = "tflite")] if matches.is_present("tflite-cycle") { stage!("tflite-cycle", typed_model -> typed_model, |m:TypedModel| { let tflite = tract_tflite::tflite(); @@ -743,6 +744,10 @@ impl Parameters { }); stage!("tflite-declutter", typed_model -> typed_model, |m:TypedModel| m.into_decluttered()); } + #[cfg(not(feature = "tflite"))] + if matches.is_present("tflite-cycle") { + bail!("This tract build did not include tflite features."); + } if let Some(sub) = matches.value_of("extract-decluttered-sub") { stage!("extract", typed_model -> typed_model, |m:TypedModel| { let node = m.node_id_by_name(sub)?;