From: Parichay Kapoor Date: Tue, 11 Feb 2020 10:19:04 +0000 (+0900) Subject: [custom/hw] Added supported accelerators X-Git-Tag: accepted/tizen/unified/20200318.130449~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddf7830078d6765add4cbb6537abfcb83f9540b1;p=platform%2Fupstream%2Fnnstreamer.git [custom/hw] Added supported accelerators Added supported accelerators for custom filters and its unit-tests with single API Signed-off-by: Parichay Kapoor --- diff --git a/gst/nnstreamer/tensor_filter/tensor_filter_custom.c b/gst/nnstreamer/tensor_filter/tensor_filter_custom.c index cd0656c..679142f 100644 --- a/gst/nnstreamer/tensor_filter/tensor_filter_custom.c +++ b/gst/nnstreamer/tensor_filter/tensor_filter_custom.c @@ -37,6 +37,12 @@ void init_filter_custom (void) __attribute__ ((constructor)); void fini_filter_custom (void) __attribute__ ((destructor)); +static const gchar *custom_accl_support[] = { + ACCL_AUTO_STR, + ACCL_DEFAULT_STR, + NULL +}; + /** * @brief internal_data */ @@ -267,6 +273,18 @@ custom_allocateInInvoke (void **private_data) return -EINVAL; } +/** + * @brief Check support of the backend + */ +static int +custom_checkAvailability (accl_hw hw) +{ + if (g_strv_contains (custom_accl_support, get_accl_hw_str (hw))) + return 0; + + return -ENOENT; +} + static gchar filter_subplugin_custom[] = "custom"; static GstTensorFilterFramework NNS_support_custom = { @@ -284,6 +302,7 @@ static GstTensorFilterFramework NNS_support_custom = { .close = custom_close, .destroyNotify = custom_destroyNotify, /* if custom filter model supports allocate_in_invoke, this will be set from custom filter. */ .allocateInInvoke = custom_allocateInInvoke, + .checkAvailability = custom_checkAvailability, }; /** @brief Initialize this object for tensor_filter subplugin runtime register */ diff --git a/tests/tizen_capi/unittest_tizen_capi.cc b/tests/tizen_capi/unittest_tizen_capi.cc index 0ff76ea..5b48fdd 100644 --- a/tests/tizen_capi/unittest_tizen_capi.cc +++ b/tests/tizen_capi/unittest_tizen_capi.cc @@ -1382,6 +1382,40 @@ TEST (nnstreamer_capi_util, availability_fail_02_n) #endif /** ENABLE_TENSORFLOW */ /** + * @brief Test NNStreamer Utility for checking availability of custom backend + */ +TEST (nnstreamer_capi_util, availability_03) +{ + bool result; + int status; + + status = ml_check_nnfw_availability (ML_NNFW_TYPE_CUSTOM_FILTER, ML_NNFW_HW_ANY, &result); + EXPECT_EQ (status, ML_ERROR_NONE); + EXPECT_EQ (result, true); + + status = ml_check_nnfw_availability (ML_NNFW_TYPE_CUSTOM_FILTER, ML_NNFW_HW_AUTO, &result); + EXPECT_EQ (status, ML_ERROR_NONE); + EXPECT_EQ (result, true); +} + +/** + * @brief Test NNStreamer Utility for checking availability of custom backend + */ +TEST (nnstreamer_capi_util, availability_fail_03_n) +{ + bool result; + int status; + + status = ml_check_nnfw_availability (ML_NNFW_TYPE_CUSTOM_FILTER, ML_NNFW_HW_CPU, &result); + EXPECT_EQ (status, ML_ERROR_NONE); + EXPECT_EQ (result, false); + + status = ml_check_nnfw_availability (ML_NNFW_TYPE_CUSTOM_FILTER, ML_NNFW_HW_GPU, &result); + EXPECT_EQ (status, ML_ERROR_NONE); + EXPECT_EQ (result, false); +} + +/** * @brief Test NNStreamer Utility for checking tensors info handle */ TEST (nnstreamer_capi_util, tensors_info)