[custom/hw] Added supported accelerators
authorParichay Kapoor <pk.kapoor@samsung.com>
Tue, 11 Feb 2020 10:19:04 +0000 (19:19 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 4 Mar 2020 04:22:08 +0000 (13:22 +0900)
Added supported accelerators for custom filters and its unit-tests with single API

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
gst/nnstreamer/tensor_filter/tensor_filter_custom.c
tests/tizen_capi/unittest_tizen_capi.cc

index cd0656c..679142f 100644 (file)
 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 */
index 0ff76ea..5b48fdd 100644 (file)
@@ -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)