From: Jaeyun Date: Fri, 17 Jul 2020 09:17:45 +0000 (+0900) Subject: [Filter/NNFW] change nnfw api X-Git-Tag: accepted/tizen/unified/20200723.161155~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=340ac3333a0c910b69e652ff5be62d0fed52ad6f;p=platform%2Fupstream%2Fnnstreamer.git [Filter/NNFW] change nnfw api 1. Change nnfw api to set input info. The function apply_tensorinfo will be deprecated soon. 2. Remove unnecessary definition about max rank of nnfw. Signed-off-by: Jaeyun --- diff --git a/ext/nnstreamer/tensor_filter/meson.build b/ext/nnstreamer/tensor_filter/meson.build index f0a0cfe..eda415f 100644 --- a/ext/nnstreamer/tensor_filter/meson.build +++ b/ext/nnstreamer/tensor_filter/meson.build @@ -6,9 +6,13 @@ if nnfw_runtime_support_is_available nnstreamer_filter_nnfw_sources += join_paths(meson.current_source_dir(), s) endforeach - nnstreamer_filter_nnfw_deps = nnfw_runtime_support_deps + [glib_dep, gst_dep, nnstreamer_dep] + # Check old function (@todo remove this definition later, nnfw ver >= 1.6.0) + if not cc.has_function('nnfw_set_input_tensorinfo', dependencies: nnfw_dep) + nnstreamer_filter_nnfw_deps += declare_dependency(compile_args: ['-DNNFW_USE_OLD_API=1']) + endif + nnfw_plugin_lib = shared_library('nnstreamer_filter_nnfw', nnstreamer_filter_nnfw_sources, dependencies: nnstreamer_filter_nnfw_deps, diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_nnfw.c b/ext/nnstreamer/tensor_filter/tensor_filter_nnfw.c index b500d6a..0444f99 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_nnfw.c +++ b/ext/nnstreamer/tensor_filter/tensor_filter_nnfw.c @@ -43,9 +43,6 @@ #define NNFW_SRCN_BACKEND "srcn" #define NNFW_DEFAULT_BACKEND NNFW_CPU_BACKEND -/** Maximum rank allowed for tensor dimension */ -#define NNFW_TENSOR_RANK_LIMIT 6 - static const gchar *nnfw_accl_support[] = { ACCL_CPU_NEON_STR, ACCL_CPU_STR, @@ -382,6 +379,7 @@ nnfw_tensor_info_set (const nnfw_pdata * pdata, const GstTensorsInfo * tensors_info, guint tensor_idx) { struct nnfw_tensorinfo nnfw_info; + NNFW_STATUS status; gint err; gint idx; const GstTensorInfo *info = &tensors_info->info[tensor_idx]; @@ -396,10 +394,21 @@ nnfw_tensor_info_set (const nnfw_pdata * pdata, for (idx = nnfw_info.rank - 1; idx >= 0; idx--) nnfw_info.dims[nnfw_info.rank - idx - 1] = info->dimension[idx]; - for (idx = NNFW_TENSOR_RANK_LIMIT - 1; idx >= nnfw_info.rank; idx--) + /** @note Maximum rank expressible with nnfw is 6 (NNFW_MAX_RANK) */ + for (idx = NNFW_MAX_RANK - 1; idx >= nnfw_info.rank; idx--) nnfw_info.dims[idx] = 0; - nnfw_apply_tensorinfo (pdata->session, tensor_idx, nnfw_info); +#if defined (NNFW_USE_OLD_API) + /** + * @todo nnfw_apply_tensorinfo() will be deprecated. + * Use nnfw_set_input_tensorinfo() later (nnfw ver >= 1.6.0). + */ + status = nnfw_apply_tensorinfo (pdata->session, tensor_idx, nnfw_info); +#else + status = nnfw_set_input_tensorinfo (pdata->session, tensor_idx, &nnfw_info); +#endif + if (status != NNFW_STATUS_NO_ERROR) + return -EPERM; return 0; }