From 705a91dae2b0baffd94fddcd5fef4b4f350bbda9 Mon Sep 17 00:00:00 2001 From: ebraraktas Date: Tue, 1 Feb 2022 12:35:46 +0300 Subject: [PATCH] Update build definitions for XNNPACK --- build.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build.rs b/build.rs index 79f7912..5652869 100644 --- a/build.rs +++ b/build.rs @@ -203,19 +203,17 @@ fn build_tensorflow_with_bazel(tf_src_path: &str, config: &str) -> PathBuf { let mut bazel = std::process::Command::new("bazel"); bazel.arg("build").arg("-c").arg("opt"); + // Configure XNNPACK flags + // In r2.6, it is enabled for some OS such as Windows by default. + // To enable it by feature flag, we disable it by default on all platforms. + #[cfg(not(feature = "xnnpack"))] + bazel.arg("--define").arg("tflite_with_xnnpack=false"); #[cfg(any(feature = "xnnpack_qu8", feature = "xnnpack_qs8"))] - { - bazel.arg("--define").arg("tflite_with_xnnpack=true"); - } - + bazel.arg("--define").arg("tflite_with_xnnpack=true"); #[cfg(feature = "xnnpack_qs8")] - { - bazel.arg("--define").arg("xnn_enable_qs8=true"); - } + bazel.arg("--define").arg("xnn_enable_qs8=true"); #[cfg(feature = "xnnpack_qu8")] - { - bazel.arg("--define").arg("xnn_enable_qu8=true"); - } + bazel.arg("--define").arg("xnn_enable_qu8=true"); bazel .arg(format!("--config={}", config))