From b4014a1549c10a3ae97a86d4f4424082a1456467 Mon Sep 17 00:00:00 2001 From: Jaeyun Date: Fri, 20 Aug 2021 15:35:39 +0900 Subject: [PATCH] [C-Api] function to check hw availability Add new function to check hw availability with custom option string. Signed-off-by: Jaeyun --- c/include/nnstreamer.h | 18 ++++++++++++++++++ c/src/nnstreamer-capi-util.c | 18 ++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/c/include/nnstreamer.h b/c/include/nnstreamer.h index 9df63bf..6a6940b 100644 --- a/c/include/nnstreamer.h +++ b/c/include/nnstreamer.h @@ -1264,6 +1264,24 @@ int ml_tensors_data_set_tensor_data (ml_tensors_data_h data, unsigned int index, int ml_check_nnfw_availability (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, bool *available); /** + * @brief Checks the availability of the given execution environments with custom option. + * @details If the function returns an error, @a available may not be changed. + * @since_tizen 6.5 + * @param[in] nnfw Check if the nnfw is available in the system. + * Set #ML_NNFW_TYPE_ANY to skip checking nnfw. + * @param[in] hw Check if the hardware is available in the system. + * Set #ML_NNFW_HW_ANY to skip checking hardware. + * @param[in] custom_option Custom option string to check framework and hardware. + * If an nnstreamer filter plugin needs to handle detailed option for hardware detection, use this parameter. + * @param[out] available @c true if it's available, @c false if it's not available. + * @return @c 0 on success. Otherwise a negative error value. + * @retval #ML_ERROR_NONE Successful and the environments are available. + * @retval #ML_ERROR_NOT_SUPPORTED Not supported. + * @retval #ML_ERROR_INVALID_PARAMETER Given parameter is invalid. + */ +int ml_check_nnfw_availability_full (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, const char *custom_option, bool *available); + +/** * @brief Checks if the element is registered and available on the pipeline. * @details If the function returns an error, @a available may not be changed. * @since_tizen 6.5 diff --git a/c/src/nnstreamer-capi-util.c b/c/src/nnstreamer-capi-util.c index 3b36b5a..9901ad1 100644 --- a/c/src/nnstreamer-capi-util.c +++ b/c/src/nnstreamer-capi-util.c @@ -1320,11 +1320,11 @@ ml_get_nnfw_type_by_subplugin_name (const char *name) } /** - * @brief Checks the availability of the given execution environments. + * @brief Checks the availability of the given execution environments with custom option. */ int -ml_check_nnfw_availability (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, - bool *available) +ml_check_nnfw_availability_full (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, + const char *custom, bool *available) { const char *fw_name = NULL; @@ -1345,7 +1345,7 @@ ml_check_nnfw_availability (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, if (nnstreamer_filter_find (fw_name) != NULL) { accl_hw accl = ml_nnfw_to_accl_hw (hw); - if (gst_tensor_filter_check_hw_availability (fw_name, accl)) { + if (gst_tensor_filter_check_hw_availability (fw_name, accl, custom)) { *available = true; } else { ml_logw ("%s is supported but not with the specified hardware.", @@ -1360,6 +1360,16 @@ ml_check_nnfw_availability (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, } /** + * @brief Checks the availability of the given execution environments. + */ +int +ml_check_nnfw_availability (ml_nnfw_type_e nnfw, ml_nnfw_hw_e hw, + bool *available) +{ + return ml_check_nnfw_availability_full (nnfw, hw, NULL, available); +} + +/** * @brief Checks the element is registered and available on the pipeline. */ int -- 2.7.4