}
break;
case ML_NNFW_TYPE_MVNC:
- g_object_set (filter_obj, "framework", "movidius-ncsdk2", "model", model, NULL);
/** @todo Verify this! (this code is not tested) */
+ g_object_set (filter_obj, "framework", "movidius-ncsdk2", "model", model, NULL);
+ break;
+ case ML_NNFW_TYPE_NNFW:
+ /* We can get the tensor meta from tf-lite model. */
+ g_object_set (filter_obj, "framework", "nnfw", "model", model, NULL);
break;
default:
/** @todo Add other fw later. */
* @param[in/out] nnfw The type of NNFW.
* @return @c 0 on success. Otherwise a negative error value.
* @retval #ML_ERROR_NONE Successful
- * @retval #ML_ERROR_NOT_SUPPORTED Not supported.
+ * @retval #ML_ERROR_NOT_SUPPORTED Not supported, or framework to support this model file is unavailable in the environment.
* @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid.
*/
int
switch (*nnfw) {
case ML_NNFW_TYPE_ANY:
if (g_str_has_suffix (path_down, ".tflite")) {
- ml_logi ("The given model [%s] is supposed a tensorflow-lite model.", model);
- *nnfw = ML_NNFW_TYPE_TENSORFLOW_LITE;
+ /**
+ * .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);
+ bool available_nnfw = FALSE, available_tflite = FALSE;
+
+ ml_check_nnfw_availability (ML_NNFW_TYPE_NNFW, ML_NNFW_HW_ANY,
+ &available_nnfw);
+ ml_check_nnfw_availability (ML_NNFW_TYPE_TENSORFLOW_LITE,
+ ML_NNFW_HW_ANY, &available_tflite);
+
+ if ((nnfw_runtime_priority && available_nnfw) ||
+ (!nnfw_runtime_priority && !available_tflite)) {
+ ml_logi ("The given model [%s] is supposed a nnfw model.", model);
+ *nnfw = ML_NNFW_TYPE_NNFW;
+ } else {
+ ml_logi ("The given model [%s] is supposed a tensorflow-lite model.", model);
+ *nnfw = ML_NNFW_TYPE_TENSORFLOW_LITE;
+ }
} else if (g_str_has_suffix (path_down, ".pb")) {
ml_logi ("The given model [%s] is supposed a tensorflow model.", model);
*nnfw = ML_NNFW_TYPE_TENSORFLOW;
ml_loge ("The given model [%s] has unknown extension.", model);
status = ML_ERROR_INVALID_PARAMETER;
}
+
+ if (status == ML_ERROR_NONE) {
+ bool available = false;
+ ml_check_nnfw_availability (*nnfw, ML_NNFW_HW_ANY, &available);
+ if (available == false)
+ status = ML_ERROR_NOT_SUPPORTED;
+ }
+
break;
case ML_NNFW_TYPE_CUSTOM_FILTER:
if (!g_str_has_suffix (path_down, NNSTREAMER_SO_FILE_EXTENSION)) {
}
break;
case ML_NNFW_TYPE_NNFW:
- /** @todo Need to check method for NNFW */
- ml_loge ("NNFW is not supported.");
- status = ML_ERROR_NOT_SUPPORTED;
+ {
+ gchar *model_path = NULL;
+ gchar *meta = NULL;
+
+ if (!g_str_has_suffix (path_down, ".tflite")) {
+ ml_loge ("The given model [%s] has invalid extension.", model);
+ status = ML_ERROR_INVALID_PARAMETER;
+ break;
+ }
+
+ model_path = g_path_get_dirname (model);
+ meta = g_build_filename (model_path, "metadata", "MANIFEST", NULL);
+ if (!g_file_test (meta, G_FILE_TEST_IS_REGULAR)) {
+ ml_loge ("The given model path [%s] is missing metadata.", model_path);
+ status = ML_ERROR_INVALID_PARAMETER;
+ }
+
+ g_free (model_path);
+ g_free (meta);
break;
+ }
case ML_NNFW_TYPE_MVNC:
/** @todo Need to check method for NCSDK2 */
ml_loge ("Intel Movidius NCSDK2 is not supported.");
}
break;
case ML_NNFW_TYPE_NNFW:
- {
- /** @todo Need to check method for NNFW */
+ if (nnstreamer_filter_find ("nnfw") == NULL) {
ml_logw ("NNFW is not supported.");
goto done;
}
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'),
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 = ''
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)
option('enable-tizen-sensor', type: 'boolean', value: false)