tflite2_compile_args += '-DUSE_TENSORFLOW2_HEADER_PATH=1'
endif
- if get_option('tflite2-gpu-delegate-support')
- # GLES dependency for tflite GPU delegate
- gles_dep = dependency('gles20', required: true)
- nnstreamer_filter_tflite2_deps += gles_dep
- tflite2_compile_args += '-DTFLITE_GPU_DELEGATE_SUPPORTED'
- endif
-
- if get_option('tflite2-nnapi-delegate-support')
- tflite2_compile_args += '-DTFLITE_NNAPI_DELEGATE_SUPPORTED'
- endif
-
+ # TODO: tflite v2.8.0+ supports build option for external delegate
+ # remove below option after that.
if get_option('tflite2-external-delegate-support')
tflite2_compile_args += '-DTFLITE_EXTERNAL_DELEGATE_SUPPORTED'
endif
- if get_option('tflite2-xnnpack-delegate-support')
- tflite2_compile_args += '-DTFLITE_XNNPACK_DELEGATE_SUPPORTED'
- endif
-
tflite2_extra_dep = declare_dependency(
compile_args : tflite2_compile_args
)
# include <tensorflow/contrib/lite/model.h>
#endif
-#ifdef TFLITE_XNNPACK_DELEGATE_SUPPORTED
+#if TFLITE_VERSION_MAJOR >= 2
# if USE_TENSORFLOW2_HEADER_PATH
# include <tensorflow2/lite/delegates/xnnpack/xnnpack_delegate.h>
-# else
-# include <tensorflow/lite/delegates/xnnpack/xnnpack_delegate.h>
-# endif
-#endif
-
-#ifdef TFLITE_NNAPI_DELEGATE_SUPPORTED
-# if USE_TENSORFLOW2_HEADER_PATH
-# include <tensorflow2/lite/delegates/nnapi/nnapi_delegate.h>
-# else
-# include <tensorflow/lite/delegates/nnapi/nnapi_delegate.h>
-# endif
-#endif
-
-#ifdef TFLITE_GPU_DELEGATE_SUPPORTED
-# if USE_TENSORFLOW2_HEADER_PATH
# include <tensorflow2/lite/delegates/gpu/delegate.h>
+# include <tensorflow2/lite/delegates/nnapi/nnapi_delegate.h>
# else
+# include <tensorflow/lite/delegates/xnnpack/xnnpack_delegate.h>
# include <tensorflow/lite/delegates/gpu/delegate.h>
+# include <tensorflow/lite/delegates/nnapi/nnapi_delegate.h>
# endif
#endif
#define TFLITE_RESOLVER_WITHOUT_DEFAULT_DELEGATES
#endif
-
/**
* @brief Macro for debug mode.
*/
switch (delegate_e) {
case TFLITE_DELEGATE_XNNPACK:
{
-#ifdef TFLITE_XNNPACK_DELEGATE_SUPPORTED
+#if TFLITE_VERSION_MAJOR >= 2
/* set xnnpack delegate */
TfLiteXNNPackDelegateOptions xnnpack_options =
TfLiteXNNPackDelegateOptionsDefault();
xnnpack_options.num_threads = (num_threads > 1) ? num_threads : 0;
is_xnnpack_delegated = true;
- ml_logw ("Input/output tensors should be memcpy-ed rather than explictly assigning its ptr when XNNPACK Delegate is used.");
+ ml_logw ("Input/output tensors should be memcpy-ed rather than explicitly assigning its ptr when XNNPACK Delegate is used.");
ml_logw ("This could cause performance degradation if sizes of input/output tensors are large");
delegate = TfLiteXNNPackDelegateCreate (&xnnpack_options);
setDelegate (delegate, deleter);
#else
- ml_logw ("XNNPACK delegate support is available only in Android with tflite v2.3.0 or higher and XNNPACK support should be enabled for tf-lite subplugin build.");
+ ml_logw ("NNStreamer was built without XNNPACK delegate. Given delegate option XNNPACK is ignored.");
#endif
break;
}
case TFLITE_DELEGATE_GPU:
{
-#ifdef TFLITE_GPU_DELEGATE_SUPPORTED
+#if TFLITE_VERSION_MAJOR >= 2
/* set gpu delegate when accelerator set to GPU */
TfLiteGpuDelegateOptionsV2 options = TfLiteGpuDelegateOptionsV2Default ();
options.experimental_flags = TFLITE_GPU_EXPERIMENTAL_FLAGS_NONE;
setDelegate (delegate, deleter);
#else
- ml_logw ("GPU delegate support is available with tflite v2.3.0 or higher");
+ ml_logw ("NNStreamer was built without GPU delegate. Given delegate option GPU is ignored.");
#endif
break;
}
case TFLITE_DELEGATE_NNAPI:
{
-#ifdef TFLITE_NNAPI_DELEGATE_SUPPORTED
+#if TFLITE_VERSION_MAJOR >= 2
/* set nnapi delegate when accelerator set to auto (cpu.neon in Android) or NPU */
delegate = new tflite::StatefulNnApiDelegate ();
void (* deleter) (TfLiteDelegate *) =
setDelegate (delegate, deleter);
#else
- ml_logw ("NNAPI delegate support is available only in Android with tflite v1.14.0 or higher");
+ ml_logw ("NNStreamer was built without NNAPI delegate. Given delegate option NNAPI is ignored.");
#endif
break;
}
setDelegate (delegate, deleter);
#else
- ml_logw ("External delegate support is available with tflite v2.4.0 or higher");
+ ml_logw ("NNStreamer was built without external delegate. Given delegate option external is ignored.");
#endif
break;
}
option('enable-test', type: 'boolean', value: true)
option('install-test', type: 'boolean', value: false)
option('enable-pytorch-use-gpu', type: 'boolean', value: false) # default value, can be specified at run time
-option('tflite2-gpu-delegate-support', type: 'boolean', value: 'false')
-option('tflite2-nnapi-delegate-support', type: 'boolean', value: 'false')
option('tflite2-external-delegate-support', type: 'boolean', value: 'false')
-option('tflite2-xnnpack-delegate-support', type: 'boolean', value: 'false')
option('enable-mediapipe', type: 'boolean', value: false)
option('enable-env-var', type: 'boolean', value: true)
option('enable-symbolic-link', type: 'boolean', value: true)
%define tensorflow_support 0
%define tensorflow_lite_support 1
%define tensorflow2_lite_support 1
-%define tensorflow2_gpu_delegate_support 1
%define armnn_support 1
%define vivante_support 0
%define flatbuf_support 1
%if 0%{?tensorflow2_lite_support}
# for tensorflow2-lite
BuildRequires: tensorflow2-lite-devel
-%if 0%{?tensorflow2_gpu_delegate_support}
-BuildRequires: pkgconfig(gles20)
-%endif
%endif
# custom_example_opencv filter requires opencv-devel
BuildRequires: opencv-devel
# Support tensorflow2-lite
%if 0%{?tensorflow2_lite_support}
-%if 0%{?tensorflow2_gpu_delegate_support}
-%define enable_tf2_lite -Dtflite2-support=enabled -Dtflite2-gpu-delegate-support=true
-%else
-%define enable_tf2_lite -Dtflite2-support=enabled -Dtflite2-gpu-delegate-support=false
-%endif
+%define enable_tf2_lite -Dtflite2-support=enabled
%else
%define enable_tf2_lite -Dtflite2-support=disabled
%endif