ml_tensors_data_s in_tensors; /**< input tensor wrapper for processing */
ml_tensors_data_s out_tensors; /**< output tensor wrapper for processing */
- /** @todo Use only ml_tensor_info_s dimension instead of saving ranks value */
- guint input_ranks[ML_TENSOR_SIZE_LIMIT]; /**< the rank list of input tensors, it is calculated based on the dimension string. */
- guint output_ranks[ML_TENSOR_SIZE_LIMIT]; /**< the rank list of output tensors, it is calculated based on the dimension string. */
-
GList *destroy_data_list; /**< data to be freed by filter */
} ml_single;
}
/**
- * @brief Initializes the rank information with default value.
- */
-static int
-_ml_tensors_rank_initialize (guint * rank)
-{
- guint i;
-
- if (!rank)
- _ml_error_report_return (ML_ERROR_INVALID_PARAMETER,
- "The parameter, rank, is NULL. Provide a valid pointer.");
-
- for (i = 0; i < ML_TENSOR_RANK_LIMIT; i++) {
- rank[i] = 0;
- }
-
- return ML_ERROR_NONE;
-}
-
-/**
- * @brief Sets the rank information with given value.
- */
-static int
-_ml_tensors_set_rank (guint * rank, guint val)
-{
- guint i;
-
- if (!rank)
- _ml_error_report_return (ML_ERROR_INVALID_PARAMETER,
- "The parameter, rank, is NULL. Provide a valid pointer.");
-
- for (i = 0; i < ML_TENSOR_RANK_LIMIT; i++) {
- rank[i] = val;
- }
-
- return ML_ERROR_NONE;
-}
-
-/**
* @brief thread to execute calls to invoke
*
* @details The thread behavior is detailed as below:
_ml_tensors_info_initialize (&single_h->in_info);
_ml_tensors_info_initialize (&single_h->out_info);
- _ml_tensors_rank_initialize (single_h->input_ranks);
- _ml_tensors_rank_initialize (single_h->output_ranks);
g_mutex_init (&single_h->mutex);
g_cond_init (&single_h->cond);
/* Setup input and output memory buffers for invoke */
if (in_tensors_info && in_tensors_info->is_extended) {
ml_tensors_info_create_extended (&single_h->in_tensors.info);
- _ml_tensors_set_rank (single_h->input_ranks, ML_TENSOR_RANK_LIMIT);
} else {
ml_tensors_info_create (&single_h->in_tensors.info);
- _ml_tensors_set_rank (single_h->input_ranks, ML_TENSOR_RANK_LIMIT_PREV);
}
if (out_tensors_info && out_tensors_info->is_extended) {
ml_tensors_info_create_extended (&single_h->out_tensors.info);
- _ml_tensors_set_rank (single_h->output_ranks, ML_TENSOR_RANK_LIMIT);
} else {
ml_tensors_info_create (&single_h->out_tensors.info);
- _ml_tensors_set_rank (single_h->output_ranks, ML_TENSOR_RANK_LIMIT_PREV);
}
__setup_in_out_tensors (single_h);
num = gst_tensors_info_parse_types_string (&gst_info, value);
else if (g_str_has_suffix (name, "name"))
num = gst_tensors_info_parse_names_string (&gst_info, value);
- else {
- guint *rank;
- gchar **str_dims;
- guint i;
-
- if (is_input) {
- rank = single_h->input_ranks;
- } else {
- rank = single_h->output_ranks;
- }
-
- str_dims = g_strsplit_set (value, ",.", -1);
- num = g_strv_length (str_dims);
-
- if (num > ML_TENSOR_SIZE_LIMIT) {
- _ml_error_report ("Invalid param, dimensions (%d) max (%d)\n",
- num, ML_TENSOR_SIZE_LIMIT);
-
- num = ML_TENSOR_SIZE_LIMIT;
- }
-
- for (i = 0; i < num; ++i) {
- rank[i] = gst_tensor_parse_dimension (str_dims[i],
- gst_tensors_info_get_nth_info (&gst_info, i)->dimension);
- }
- g_strfreev (str_dims);
- }
+ else
+ num = gst_tensors_info_parse_dimensions_string (&gst_info, value);
if (num == gst_info.num_tensors) {
ml_tensors_info_h ml_info;
ML_SINGLE_GET_VALID_HANDLE_LOCKED (single_h, single, 0);
- if (g_str_equal (name, "inputtype") || g_str_equal (name, "inputname") ||
+ if (g_str_equal (name, "input") || g_str_equal (name, "output") ||
+ g_str_equal (name, "inputtype") || g_str_equal (name, "inputname") ||
g_str_equal (name, "inputlayout") || g_str_equal (name, "outputtype") ||
g_str_equal (name, "outputname") || g_str_equal (name, "outputlayout") ||
g_str_equal (name, "accelerator") || g_str_equal (name, "custom")) {
/* boolean */
g_object_get (G_OBJECT (single_h->filter), name, &bool_value, NULL);
*value = (bool_value) ? g_strdup ("true") : g_strdup ("false");
- } else if (g_str_equal (name, "input") || g_str_equal (name, "output")) {
- gchar *dim_str = NULL;
- const guint *rank;
- gboolean is_input = g_str_has_prefix (name, "input");
- GstTensorsInfo gst_info;
-
- if (is_input) {
- rank = single_h->input_ranks;
- } else {
- rank = single_h->output_ranks;
- }
-
- ml_single_get_gst_info (single_h, is_input, &gst_info);
-
- if (gst_info.num_tensors > 0) {
- guint i;
- GString *dimensions = g_string_new (NULL);
-
- for (i = 0; i < gst_info.num_tensors; ++i) {
- dim_str =
- gst_tensor_get_rank_dimension_string (gst_tensors_info_get_nth_info
- (&gst_info, i)->dimension, *(rank + i));
- g_string_append (dimensions, dim_str);
-
- if (i < gst_info.num_tensors - 1) {
- g_string_append (dimensions, ",");
- }
- g_free (dim_str);
- }
- dim_str = g_string_free (dimensions, FALSE);
- } else {
- dim_str = g_strdup ("");
- }
- *value = dim_str;
-
- gst_tensors_info_free (&gst_info);
} else {
_ml_error_report
("The property key, '%s', is not available for get_property and not recognized by the API. It should be one of {input, inputtype, inputname, inputlayout, output, outputtype, outputname, outputlayout, accelerator, custom, is-updatable}.",