[TF2-Lite] Use tensorflow2 directory for include path.
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 26 May 2021 00:55:24 +0000 (09:55 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 26 May 2021 12:36:29 +0000 (21:36 +0900)
If tensorflow2 headers appear in tensorflow2 directory, use it.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
ext/nnstreamer/tensor_filter/meson.build
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.cc

index 0f1b26b..0f4b2a2 100644 (file)
@@ -206,6 +206,10 @@ if tflite2_support_is_available
   tflite2_compile_args += '-DTFLITE_FLOAT16=1'
   tflite2_compile_args += '-DTFLITE_COMPLEX64=1'
 
+  if cc.has_header('tensorflow2/lite/model.h')
+    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)
index 04792ae..085a4dc 100644 (file)
 #include <nnstreamer_conf.h>
 
 #if TFLITE_VERSION_MAJOR >= 2 || TFLITE_VERSION_MINOR >= 13
-#include <tensorflow/lite/kernels/register.h>
-#include <tensorflow/lite/model.h>
+#  if USE_TENSORFLOW2_HEADER_PATH
+#    include <tensorflow2/lite/kernels/register.h>
+#    include <tensorflow2/lite/model.h>
+#  else
+#    include <tensorflow/lite/kernels/register.h>
+#    include <tensorflow/lite/model.h>
+#  endif
 #else
-#include <tensorflow/contrib/lite/kernels/register.h>
-#include <tensorflow/contrib/lite/model.h>
+#  include <tensorflow/contrib/lite/kernels/register.h>
+#  include <tensorflow/contrib/lite/model.h>
 #endif
 
 #ifdef TFLITE_XNNPACK_DELEGATE_SUPPORTED
-#include <tensorflow/lite/delegates/xnnpack/xnnpack_delegate.h>
+#  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
-#include <tensorflow/lite/delegates/nnapi/nnapi_delegate.h>
+#  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
-#include <tensorflow/lite/delegates/gpu/delegate.h>
+#  if USE_TENSORFLOW2_HEADER_PATH
+#    include <tensorflow2/lite/delegates/gpu/delegate.h>
+#  else
+#    include <tensorflow/lite/delegates/gpu/delegate.h>
+#  endif
 #endif
 
 #if !defined(TFLITE_SUBPLUGIN_NAME)