nnstreamer_filter_tflite2_deps = tflite2_support_deps + [thread_dep, libdl_dep, nnstreamer_single_dep]
- tflite2_compile_args = ['-DTFLITE_SUBPLUGIN_NAME="tensorflow2-lite"']
+ tflite2_compile_args = []
tflite2_compile_args += '-DTFLITE_INT8=1'
tflite2_compile_args += '-DTFLITE_INT16=1'
tflite2_compile_args += '-DTFLITE_FLOAT16=1'
tflite2_compile_args += '-DTFLITE_EXTERNAL_DELEGATE_SUPPORTED'
endif
+ tflite2_custom_compile_args = tflite2_compile_args
+ tflite2_compile_args += '-DTFLITE_SUBPLUGIN_NAME="tensorflow2-lite"'
+
tflite2_extra_dep = declare_dependency(
compile_args : tflite2_compile_args
)
install: true,
install_dir: nnstreamer_libdir
)
+
+
+ if get_option('tflite2-custom-support').enabled() or get_option('tflite2-custom-support').auto()
+ ## Create libtensorflow2-lite-custom.so support.
+
+ ## @todo This assumes the same tflite version with the above.
+ ## If the user has downloaded libtensorflow-lite manually, it may incur inconsistency.
+ ## @todo This does not use pkgconfig or find_library/meson-dep info
+ ## because it does not allow querying libpath and static/shared of a dependency object.
+ ## @todo If we are allowed to use meson > 0.53, use "FS" module!
+
+ filepaths = [
+ join_paths(meson.current_source_dir(), 'libtensorflow2-lite.so',),
+ join_paths(meson.current_build_dir(), 'libtensorflow2-lite.so',),
+ join_paths(nnstreamer_libdir, 'libtensorflow2-lite.so'),
+ '/usr/lib/libtensorflow2-lite.so',
+ '/usr/lib64/libtensorflow2-lite.so',
+ './libtensorflow2-lite.so',
+ ]
+ filepath = ''
+ foreach file : filepaths
+ if run_command('bash', '-c', '[ -f "' + file + '" ]').returncode() == 0
+ message('Found: ' + file)
+ filepath = file
+ configure_file (
+ input: file,
+ output: 'libtensorflow2-lite-custom.so',
+ copy: true
+ )
+ break
+ endif
+ endforeach
+
+ if filepath == ''
+ ## No shared tfl lib found. Get static lib and convert it
+
+ filepaths = [join_paths(nnstreamer_libdir, 'libtensorflow2-lite.a'),
+ '/usr/lib/libtensorflow2-lite.a',
+ '/usr/lib64/libtensorflow2-lite.a',
+ './libtensorflow2-lite.a',
+ join_paths(meson.current_build_dir(), 'libtensorflow2-lite.a',),
+ join_paths(meson.current_source_dir(), 'libtensorflow2-lite.a',)]
+
+ foreach file : filepaths
+ if run_command('bash', '-c', '[ -f "'+ file + '" ]').returncode() == 0
+ somake = run_command('gcc', '-shared', '-o', 'libtensorflow2-lite-custom.so', '-Wl,--whole-archive', file, '-Wl,--no-whole-archive')
+ if somake.returncode() == 0
+ message('Successfully created libtensorflow2-lite-custom.so from archive: ' + file)
+ configure_file (
+ input: join_paths(meson.current_source_dir(), 'libtensorflow2-lite-custom.so'),
+ output: 'libtensorflow2-lite-custom.so',
+ copy: true
+ )
+ filepath = file
+ break
+ else
+ error('Cannot create .so from: ' + file)
+ endif
+ endif
+ endforeach
+ endif
+
+ if filepath != ''
+ tflite2_custom_compile_args += '-DTFLITE_SUBPLUGIN_NAME="tensorflow2-lite-custom"'
+ tflite2_custom_extra_dep = declare_dependency( compile_args : tflite2_custom_compile_args )
+ tflc_dep = declare_dependency (
+ link_args: ['-L' + meson.current_build_dir(), '-ltensorflow2-lite-custom']
+ )
+ shared_library('nnstreamer_filter_tensorflow2-lite-custom',
+ nnstreamer_filter_tflite2_sources,
+ dependencies: [tflc_dep, thread_dep, libdl_dep, nnstreamer_single_dep, tflite2_ver_dep, tflite2_custom_extra_dep],
+ install: true,
+ install_dir:filter_subplugin_install_dir
+ )
+ else # no custom mode built
+ if get_option('tflite2-custom-support').enabled()
+ error('Cannot create tflite2-custom tensor-filter subplugin. No valid .so/.a of tensorflow2-lite found.')
+ endif
+ endif
+ endif
+else # no tflite2
+ if get_option('tflite2-custom-support').enabled()
+ error('tflite2-custom-support requires tflite2-support')
+ endif
endif
if pytorch_support_is_available