g_return_if_fail (config != NULL);
- config->rank = 0;
config->type = _NNS_END;
for (i = 0; i < NNS_TENSOR_RANK_LIMIT; i++) {
g_return_val_if_fail (config != NULL, FALSE);
- if (config->rank == 0) {
- return FALSE;
- }
-
if (config->type == _NNS_END) {
return FALSE;
}
g_return_val_if_fail (c1 != NULL, FALSE);
g_return_val_if_fail (c2 != NULL, FALSE);
- if (c1->rank != c2->rank) {
- return FALSE;
- }
-
if (c1->type != c2->type) {
return FALSE;
}
return FALSE;
}
- gst_structure_get_int (structure, "rank", &config->rank);
gst_structure_get_int (structure, "dim1", (gint *) (&config->dimension[0]));
gst_structure_get_int (structure, "dim2", (gint *) (&config->dimension[1]));
gst_structure_get_int (structure, "dim3", (gint *) (&config->dimension[2]));
gst_tensor_config_init (config);
- /** @todo remove rank */
- config->rank = 3;
-
/** [color-space][width][height][frames] */
switch (v_info->format) {
case GST_VIDEO_FORMAT_GRAY8:
gst_tensor_config_init (config);
- /** @todo remove rank */
- config->rank = 2;
-
/** [channels][frames] */
switch (a_info->format) {
case GST_AUDIO_FORMAT_S8:
gst_tensor_config_init (config);
- /** @todo remove rank */
- config->rank = 2;
-
/** [size][frames] */
switch (t_info->format) {
case 1:
caps = gst_caps_from_string (GST_TENSOR_CAP_DEFAULT);
- if (config->rank > 0) {
- gst_caps_set_simple (caps, "rank", G_TYPE_INT, config->rank, NULL);
- }
-
if (config->dimension[0] > 0) {
gst_caps_set_simple (caps, "dim1", G_TYPE_INT, config->dimension[0], NULL);
}
{
GstTensor_Filter_CheckStatus ret = _TFC_INIT;
const gchar *strval;
- int rank;
- int j;
gint fn, fd;
if (!gst_structure_has_name (str, "other/tensor"))
gst_structure_get_int (str, "dim3", (int *) &dim[2]) &&
gst_structure_get_int (str, "dim4", (int *) &dim[3])) {
ret |= _TFC_DIMENSION;
- if (gst_structure_get_int (str, "rank", &rank)) {
- for (j = rank; j < NNS_TENSOR_RANK_LIMIT; j++)
- g_assert (dim[j] == 1);
- }
}
strval = gst_structure_get_string (str, "type");
if (strval) {
meta->num_tensors = num;
- strval = gst_structure_get_string (str, "rank");
-
- strv = g_strsplit (strval, ",./", -1);
- counter = 0;
- while (strv[counter]) {
- rank[counter] = g_ascii_strtod (strv[counter], NULL);
- if (rank[counter] != NNS_TENSOR_RANK_LIMIT) {
- err_print ("rank value of other/tensors incorrect.\n");
- rank[counter] = 0;
- return 0;
- }
- counter++;
- }
-
- g_strfreev (strv);
-
if (gst_structure_get_fraction (str, "framerate", &fn, &fd)) {
if (framerate_num)
*framerate_num = fn;
gst_event_unref (event);
caps_string = g_strdup_printf ("other/tensor, "
- "rank = (int)4, "
"type = (string)%s,"
"framerate = (fraction) %d/%d, "
"dim1 = (int) %d, "
filter->prop.fw->fwClosed = TRUE; \
} while (0);
-/**
- * @brief Calculate the rank of a tensor
- * @param dimension The dimension vector (tensor_dim = uint32_t[NNS_TENSOR_RANK_LIMIT]) of tensor.
- * @return the rank value
- */
-static int
-gst_tensor_filter_get_rank (const tensor_dim dimension)
-{
- int i = 0;
- int rank = 0;
- g_assert (dimension);
- for (i = 0; i < NNS_TENSOR_RANK_LIMIT; i++) {
- g_assert (dimension[i] > 0);
- if (dimension[i] > 1)
- rank = i + 1;
- }
- if (rank == 0) /* a scalar (assume it is 1-dim vector) */
- return 1;
- return rank;
-}
-
static GstTensor_Filter_CheckStatus
gst_tensor_filter_generate_dim_from_cap (GstCaps * caps, const tensor_dim dim,
tensor_type * type);
GstTensor_Filter_Properties *prop = &filter->prop;
GstCaps *tmp = NULL, *tmp2 = NULL, *staticcap = NULL, *resultCaps = NULL;
GstStaticCaps rawcap = GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT);
- int rank;
staticcap = gst_static_caps_get (&rawcap);
if (isInput == TRUE) {
/* 2. configure caps based on type & dimension */
if (configured == _TFC_ALL) {
- rank = gst_tensor_filter_get_rank (dimension[0]);
tmp2 =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank, "type",
+ gst_caps_new_simple ("other/tensor", "type",
G_TYPE_STRING, tensor_element_typename[type[0]], "dim1", G_TYPE_INT,
dimension[0][0], "dim2", G_TYPE_INT, dimension[0][1], "dim3",
G_TYPE_INT, dimension[0][2], "dim4", G_TYPE_INT, dimension[0][3], NULL);
tmp = gst_caps_intersect_full (staticcap, tmp2, GST_CAPS_INTERSECT_FIRST);
gst_caps_unref (tmp2);
} else if (configured == _TFC_DIMENSION) {
- rank = gst_tensor_filter_get_rank (dimension[0]);
tmp2 =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank, "dim1",
+ gst_caps_new_simple ("other/tensor", "dim1",
G_TYPE_INT, dimension[0][0], "dim2", G_TYPE_INT, dimension[0][1],
"dim3", G_TYPE_INT, dimension[0][2], "dim4", G_TYPE_INT,
dimension[0][3], NULL);
/* 3-1.2. Configure resultCap from rdim/rtype */
if (resultCaps == NULL) {
- rank = gst_tensor_filter_get_rank (outputMeta.dims[0]);
resultCaps =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank, "type",
+ gst_caps_new_simple ("other/tensor", "type",
G_TYPE_STRING, tensor_element_typename[outputMeta.types[0]], "dim1",
G_TYPE_INT, outputMeta.dims[0][0], "dim2", G_TYPE_INT,
outputMeta.dims[0][1], "dim3", G_TYPE_INT, outputMeta.dims[0][2],
/* 3-1.2. Configure resultCap from rdim/rtype */
if (resultCaps == NULL) {
- rank = gst_tensor_filter_get_rank (meta.dims[0]);
resultCaps =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank,
+ gst_caps_new_simple ("other/tensor",
"type", G_TYPE_STRING, tensor_element_typename[meta.types[0]], "dim1",
G_TYPE_INT, meta.dims[0][0], "dim2", G_TYPE_INT, meta.dims[0][1],
"dim3", G_TYPE_INT, meta.dims[0][2], "dim4", G_TYPE_INT,
unsigned int i, capsize;
const GstStructure *str;
GstTensor_Filter_CheckStatus ret = _TFC_INIT;
- int rank;
const gchar *strval;
if (!caps) {
gst_structure_get_int (str, "dim2", (int *) &dim[1]) &&
gst_structure_get_int (str, "dim3", (int *) &dim[2]) &&
gst_structure_get_int (str, "dim4", (int *) &dim[3])) {
- int j;
ret |= _TFC_DIMENSION;
- if (gst_structure_get_int (str, "rank", &rank)) {
- for (j = rank; j < NNS_TENSOR_RANK_LIMIT; j++)
- g_assert (dim[j] == 1);
- }
}
strval = gst_structure_get_string (str, "type");
if (strval) {
if (!tensor_mux->negotiated) {
GstCaps *newcaps;
newcaps =
- gst_caps_new_simple ("other/tensors", "rank", G_TYPE_INT,
- tensor_mux->rank, "num_tensors", G_TYPE_INT,
+ gst_caps_new_simple ("other/tensors",
+ "num_tensors", G_TYPE_INT,
tensor_mux->num_tensors, "types", G_TYPE_STRING,
types->str, "framerate", GST_TYPE_FRACTION,
tensor_mux->framerate_numerator, tensor_mux->framerate_denominator,
}
/**
- * @brief Calculate the rank of a tensor
- * @param dimension The dimension vector (tensor_dim = uint32_t[NNS_TENSOR_RANK_LIMIT]) of tensor.
- * @return the rank value
- */
-static int
-get_rank (const tensor_dim dimension)
-{
- int i = 0;
- int rank = 0;
- g_assert (dimension);
- for (i = 0; i < NNS_TENSOR_RANK_LIMIT; i++) {
- g_assert (dimension[i] > 0);
- if (dimension[i] > 1)
- rank = i + 1;
- }
- if (rank == 0) /* a scalar (assume it is 1-dim vector) */
- return 1;
- return rank;
-}
-
-/**
* @brief Write cap from the given dim/type. You need to free the returned value
* @param[in] dim The given tensor dimension
* @param[in] type The given tensor element type
static GstCaps *
gst_tensor_write_cap (const tensor_dim dim, tensor_type type, gint fn, gint fd)
{
- int rank = get_rank (dim);
GstStaticCaps rawcap = GST_STATIC_CAPS (GST_TENSOR_CAP_DEFAULT);
GstCaps *tmp, *tmp2;
GstCaps *staticcap = gst_static_caps_get (&rawcap);
/* type: certain. dim: uncertain */
if (fn != -1 && fd != -1) {
tmp2 =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank,
+ gst_caps_new_simple ("other/tensor",
"dim1", G_TYPE_INT, dim[0], "dim2", G_TYPE_INT, dim[1],
"dim3", G_TYPE_INT, dim[2], "dim4", G_TYPE_INT, dim[3],
"framerate", GST_TYPE_FRACTION, fn, fd, NULL);
} else {
tmp2 =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank,
+ gst_caps_new_simple ("other/tensor",
"dim1", G_TYPE_INT, dim[0], "dim2", G_TYPE_INT, dim[1],
"dim3", G_TYPE_INT, dim[2], "dim4", G_TYPE_INT, dim[3], NULL);
}
/* type: certain. dim: certain */
if (fn != -1 && fd != -1) {
tmp2 =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank, "type",
+ gst_caps_new_simple ("other/tensor", "type",
G_TYPE_STRING, tensor_element_typename[type], "dim1", G_TYPE_INT,
dim[0], "dim2", G_TYPE_INT, dim[1], "dim3", G_TYPE_INT,
dim[2], "dim4", G_TYPE_INT, dim[3],
"framerate", GST_TYPE_FRACTION, fn, fd, NULL);
} else {
tmp2 =
- gst_caps_new_simple ("other/tensor", "rank", G_TYPE_INT, rank, "type",
+ gst_caps_new_simple ("other/tensor", "type",
G_TYPE_STRING, tensor_element_typename[type], "dim1", G_TYPE_INT,
dim[0], "dim2", G_TYPE_INT, dim[1], "dim3", G_TYPE_INT,
dim[2], "dim4", G_TYPE_INT, dim[3], NULL);
GST_TENSOR_TEXT_CAPS_STR
/** @todo I'm not sure if the range is to be 1, 65535 or larger */
-#define GST_TENSOR_RANK_RANGE "(int) [ 1, 4 ]"
#define GST_TENSOR_DIM_RANGE "(int) [ 1, 65535 ]"
#define GST_TENSOR_RATE_RANGE "(fraction) [ 0/1, 2147483647/1 ]"
#define GST_TENSOR_TYPE_ALL "{ float32, float64, int64, uint64, int32, uint32, int16, uint16, int8, uint8 }"
#define GST_TENSOR_CAP_DEFAULT \
"other/tensor, " \
- "rank = " GST_TENSOR_RANK_RANGE ", " \
"dim1 = " GST_TENSOR_DIM_RANGE ", " \
"dim2 = " GST_TENSOR_DIM_RANGE ", " \
"dim3 = " GST_TENSOR_DIM_RANGE ", " \
*/
#define GST_TENSORS_CAP_DEFAULT \
"other/tensors, " \
- "rank = " GST_TENSOR_RANK_RANGE ", " \
"num_tensors = " GST_TENSOR_NUM_TENSORS_RANGE ", "\
"framerate = " GST_TENSOR_RATE_RANGE
/**
*/
typedef struct
{
- /**
- * @todo remove rank.
- */
- gint rank; /**< Tensor Rank (# dimensions) */
tensor_type type; /**< Type of each element in the tensor. User must designate this. Otherwise, this is UINT8 for video/x-raw byte stream */
tensor_dim dimension; /**< Dimensions. We support up to 4th ranks. */
gint rate_n; /**< framerate is in fraction, which is numerator/denominator */