This patch supports the GPU Delegate functionality on Tizen platform.
NNStreamer filter for TFLite2 GPU delegate only supports OpenCL backend
since GLES v3.1 backend has a constraint that Invoke() must be called
from the same EGLContext.
If both tensorflow2_lite_support and tensorflow2_gpu_delegate_support
are set as 1 in nnstreamer.spec, GPU Delegate functionality is enabled.
If tensorflow2_gpu_delegate_support is set but tensorflow2_lite_support
is 0, then tensorflow2_gpu_delegate_support option is ignored.
Since Tensorflow2 GPU delegate is ready,
tensorflow2_gpu_delegate_support is set as 1 in this patch.
Signed-off-by: Sangjung Woo <sangjung.woo@samsung.com>
tflite2_compile_args += '-DTFLITE_FLOAT16=1'
tflite2_compile_args += '-DTFLITE_COMPLEX64=1'
+ 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
+
tflite2_extra_dep = declare_dependency(
compile_args : tflite2_compile_args
)
options.experimental_flags = TFLITE_GPU_EXPERIMENTAL_FLAGS_NONE;
options.experimental_flags |= TFLITE_GPU_EXPERIMENTAL_FLAGS_ENABLE_QUANT;
+ /** NNStreamer filter for TFLite2 GPU delegate only supports OpenCL backend
+ * since GLES v3.1 backend has a constraint that
+ * Invoke() must be called from the same EGLContext. */
+ options.experimental_flags |= TFLITE_GPU_EXPERIMENTAL_FLAGS_CL_ONLY;
+ options.inference_priority1 = TFLITE_GPU_INFERENCE_PRIORITY_MIN_LATENCY;
+ options.inference_priority2 = TFLITE_GPU_INFERENCE_PRIORITY_MIN_MEMORY_USAGE;
+ options.inference_priority3 = TFLITE_GPU_INFERENCE_PRIORITY_MAX_PRECISION;
+
gpu_delegate.reset (TfLiteGpuDelegateV2Create (&options));
setDelegate (gpu_delegate.get ());
#else
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('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 0
%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}
-%define enable_tf2_lite -Dtflite2-support=enabled
+%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
%else
%define enable_tf2_lite -Dtflite2-support=disabled
%endif