gst_tensors_info_free (GstTensorsInfo * info);
/**
+ * @brief Get data size of single tensor
+ * @param info tensors info structure
+ * @param index the index of tensor (-1 to get total size of tensors)
+ * @return data size
+ */
+gsize
+gst_tensors_info_get_size (const GstTensorsInfo * info, gint index);
+
+/**
* @brief Parse the string of dimensions
* @param info tensors info structure
* @param dim_string string of dimensions
}
/**
+ * @brief Get data size of single tensor
+ * @param info tensors info structure
+ * @param index the index of tensor (-1 to get total size of tensors)
+ * @return data size
+ */
+gsize
+gst_tensors_info_get_size (const GstTensorsInfo * info, gint index)
+{
+ gsize data_size = 0;
+ guint i;
+
+ g_return_val_if_fail (info != NULL, 0);
+ g_return_val_if_fail (index < (gint) info->num_tensors, 0);
+
+ if (index < 0) {
+ for (i = 0; i < info->num_tensors; ++i)
+ data_size += gst_tensor_info_get_size (&info->info[i]);
+ } else {
+ data_size = gst_tensor_info_get_size (&info->info[index]);
+ }
+
+ return data_size;
+}
+
+/**
* @brief Check the tensors info is valid
* @param info tensors info structure
* @return TRUE if info is valid
}
/**
+ * @brief Test for data size.
+ */
+TEST (common_tensor_info, size_01_p)
+{
+ GstTensorsInfo info1, info2;
+ gsize size1, size2;
+ guint i;
+
+ fill_tensors_info_for_test (&info1, &info2);
+
+ size1 = gst_tensor_info_get_size (&info1.info[0]);
+ size2 = gst_tensors_info_get_size (&info1, 0);
+
+ EXPECT_TRUE (size1 == size2);
+
+ size1 = 0;
+ for (i = 0; i < info2.num_tensors; i++) {
+ size1 += gst_tensor_info_get_size (&info2.info[i]);
+ }
+
+ size2 = gst_tensors_info_get_size (&info2, -1);
+
+ EXPECT_TRUE (size1 == size2);
+}
+
+/**
+ * @brief Test for data size.
+ */
+TEST (common_tensor_info, size_02_n)
+{
+ GstTensorsInfo info1, info2;
+ gsize size1;
+ gint index;
+
+ fill_tensors_info_for_test (&info1, &info2);
+
+ /* get size with null param */
+ index = (gint) info1.num_tensors - 1;
+ size1 = gst_tensors_info_get_size (NULL, index);
+
+ EXPECT_TRUE (size1 == 0);
+}
+
+/**
+ * @brief Test for data size.
+ */
+TEST (common_tensor_info, size_03_n)
+{
+ GstTensorsInfo info1, info2;
+ gsize size1;
+ gint index;
+
+ fill_tensors_info_for_test (&info1, &info2);
+
+ /* get size with invalid index */
+ index = (gint) info1.num_tensors;
+ size1 = gst_tensors_info_get_size (&info1, index);
+
+ EXPECT_TRUE (size1 == 0);
+}
+
+/**
* @brief Test for same tensors info.
*/
TEST (common_tensor_info, equal_01_p)