#include "nnstreamer_plugin_api.h"
#include "nnstreamer_plugin_api_filter.h"
#include "nnstreamer_conf.h"
+#include <tensor_filter/tensor_filter_common.h>
/**
* @brief Allocates a tensors information handle with default value.
/** @todo This is a hotfix. Make a general mechanism instead! (n paths) */
gchar *path_down, *path_down_2 = NULL;
int status = ML_ERROR_NONE;
+ gchar *detected_fw = NULL;
if (!model) {
ml_loge ("The required param, model is not provided (null).");
switch (*nnfw) {
case ML_NNFW_TYPE_ANY:
- /** @todo Make sure num_models is correct */
- if (g_str_has_suffix (path_down, ".tflite")) {
- /**
- * .tflite is supported by both tensorflow and nnfw.
- * Priority decided with ini file.
- */
- gboolean nnfw_runtime_priority =
- nnsconf_get_custom_value_bool ("nnfw-runtime",
- "prioritize_tflite_ext", FALSE);
- gboolean available_nnfw =
- ml_nnfw_is_available (ML_NNFW_TYPE_NNFW, ML_NNFW_HW_ANY);
- gboolean available_tflite =
- ml_nnfw_is_available (ML_NNFW_TYPE_TENSORFLOW_LITE, ML_NNFW_HW_ANY);
-
- if ((nnfw_runtime_priority && available_nnfw) ||
- (!nnfw_runtime_priority && !available_tflite)) {
- ml_logi ("The given model [%s] is supposed a nnfw model.", model[0]);
- *nnfw = ML_NNFW_TYPE_NNFW;
- } else {
- ml_logi ("The given model [%s] is supposed a tensorflow-lite model.",
- model[0]);
- *nnfw = ML_NNFW_TYPE_TENSORFLOW_LITE;
- }
- } else if ((g_str_has_suffix (path_down, ".so") &&
- g_str_has_suffix (path_down_2, ".nb")) ||
- (g_str_has_suffix (path_down, ".nb") &&
- g_str_has_suffix (path_down_2, ".so"))) {
+ detected_fw =
+ gst_tensor_filter_framework_auto_detection ((const gchar **) model,
+ num_models);
+
+ if (detected_fw == NULL) {
+ ml_loge ("The given model [%s] has unknown or not supported extension.",
+ model[0]);
+ status = ML_ERROR_INVALID_PARAMETER;
+ } else if (g_ascii_strcasecmp (detected_fw, "nnfw") == 0) {
+ ml_logi ("The given model [%s] is supposed a nnfw model.", model[0]);
+ *nnfw = ML_NNFW_TYPE_NNFW;
+ } else if (g_ascii_strcasecmp (detected_fw, "tensorflow-lite") == 0) {
+ ml_logi ("The given model [%s] is supposed a tensorflow-lite model.",
+ model[0]);
+ *nnfw = ML_NNFW_TYPE_TENSORFLOW_LITE;
+ } else if (g_ascii_strcasecmp (detected_fw, "vivante") == 0) {
ml_logi ("The given model [%s,%s] looks like a Vivante model.",
model[0], model[1]);
*nnfw = ML_NNFW_TYPE_VIVANTE;
- } else if (g_str_has_suffix (path_down, ".pb")) {
+ } else if (g_ascii_strcasecmp (detected_fw, "tensorflow") == 0) {
ml_logi ("The given model [%s] is supposed a tensorflow model.",
model[0]);
*nnfw = ML_NNFW_TYPE_TENSORFLOW;
- } else if (g_str_has_suffix (path_down, NNSTREAMER_SO_FILE_EXTENSION)) {
+ } else if (g_ascii_strcasecmp (detected_fw, "custom") == 0) {
ml_logi ("The given model [%s] is supposed a custom filter model.",
model[0]);
*nnfw = ML_NNFW_TYPE_CUSTOM_FILTER;
} else {
- ml_loge ("The given model [%s] has unknown extension.", model[0]);
+ ml_loge ("The given model [%s] has unknown or not supported extension.",
+ model[0]);
status = ML_ERROR_INVALID_PARAMETER;
}
status = ML_ERROR_NOT_SUPPORTED;
}
+ if (detected_fw != NULL)
+ g_free (detected_fw);
+
break;
case ML_NNFW_TYPE_CUSTOM_FILTER:
/** @todo Make sure num_models is correct */
nnstreamer_install_conf.set('ENABLE_ENV_VAR', get_option('enable-env-var'))
nnstreamer_install_conf.set('ENABLE_SYMBOLIC_LINK', get_option('enable-symbolic-link'))
nnstreamer_install_conf.set('TORCH_USE_GPU', get_option('enable-pytorch-use-gpu'))
-nnstreamer_install_conf.set('NNFW_RUNTIME_PRIORITIZE', get_option('nnfw-runtime-prioritize'))
# Element restriction
restriction_config = ''
nnstreamer_test_conf.set('ENABLE_SYMBOLIC_LINK', false)
nnstreamer_test_conf.set('TORCH_USE_GPU', false)
nnstreamer_test_conf.set('ELEMENT_RESTRICTION_CONFIG', '')
- nnstreamer_test_conf.set('NNFW_RUNTIME_PRIORITIZE', false)
configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer-test.ini',
install: get_option('install-test'),
option('restricted-elements', type: 'string', value: '')
option('enable-tflite-nnapi-delegation', type: 'boolean', value: false) # true to enable tensorflow-lite to delegate nnapi interpretation to nnfw backend in tizen
option('enable-nnfw-runtime', type: 'boolean', value: false) # true to enable nnfw tensor filter element
-option('nnfw-runtime-prioritize', type: 'boolean', value: false) # true to set higher priority for nnfw for tflite extension files in auto mode
option('enable-cppfilter', type: 'boolean', value: true) # Allows C++ custom filters
option('enable-filter-cpp-class', type: 'boolean', value: false) # Allows to accept C++ classes as filter subplugin implementation.
option('enable-tizen-sensor', type: 'boolean', value: false)