[_NNS_UINT8] = "uint8",
[_NNS_FLOAT64] = "float64",
[_NNS_FLOAT32] = "float32",
+ [_NNS_INT64] = "int64",
+ [_NNS_UINT64] = "uint64",
[_NNS_END] = NULL,
};
g_return_val_if_fail (config->tensor_media_type == _NNS_VIDEO, FALSE);
- v_info->format = (GstVideoFormat) config->media_format;
+ v_info->format = (GstVideoFormat) config->tensor_media_format;
v_info->w = config->dimension[1];
v_info->h = config->dimension[2];
v_info->fn = config->rate_n;
g_return_val_if_fail (config->tensor_media_type == _NNS_AUDIO, FALSE);
- a_info->format = (GstAudioFormat) config->media_format;
+ a_info->format = (GstAudioFormat) config->tensor_media_format;
a_info->ch = config->dimension[0];
a_info->frames = config->dimension[1];
a_info->rate = config->rate_n;
config->rate_d = -1;
config->frame_size = 0;
config->tensor_media_type = _NNS_MEDIA_END;
- config->media_format = 0;
+ config->tensor_media_format = 0;
}
/**
return FALSE;
}
- if (config->frame_size == 0 || config->media_format == 0) {
+ if (config->frame_size == 0 || config->tensor_media_format == 0) {
return FALSE;
}
return FALSE;
}
- if (c1->media_format != c2->media_format) {
+ if (c1->tensor_media_format != c2->tensor_media_format) {
return FALSE;
}
if (config->type == _NNS_UINT8) {
switch (config->dimension[0]) {
case 3:
- config->media_format = GST_VIDEO_FORMAT_RGB;
+ config->tensor_media_format = GST_VIDEO_FORMAT_RGB;
break;
case 4:
- config->media_format = GST_VIDEO_FORMAT_BGRx;
+ config->tensor_media_format = GST_VIDEO_FORMAT_BGRx;
break;
default:
- config->media_format = GST_VIDEO_FORMAT_UNKNOWN;
+ config->tensor_media_format = GST_VIDEO_FORMAT_UNKNOWN;
break;
}
}
} else if (config->tensor_media_type == _NNS_AUDIO) {
switch (config->type) {
case _NNS_INT8:
- config->media_format = GST_AUDIO_FORMAT_S8;
+ config->tensor_media_format = GST_AUDIO_FORMAT_S8;
break;
case _NNS_UINT8:
- config->media_format = GST_AUDIO_FORMAT_U8;
+ config->tensor_media_format = GST_AUDIO_FORMAT_U8;
break;
case _NNS_INT16:
- config->media_format = GST_AUDIO_FORMAT_S16;
+ config->tensor_media_format = GST_AUDIO_FORMAT_S16;
break;
case _NNS_UINT16:
- config->media_format = GST_AUDIO_FORMAT_U16;
+ config->tensor_media_format = GST_AUDIO_FORMAT_U16;
break;
default:
- config->media_format = GST_AUDIO_FORMAT_UNKNOWN;
+ config->tensor_media_format = GST_AUDIO_FORMAT_UNKNOWN;
break;
}
}
}
config->tensor_media_type = _NNS_VIDEO;
- config->media_format = v_info->format;
+ config->tensor_media_format = v_info->format;
return res;
}
}
config->tensor_media_type = _NNS_AUDIO;
- config->media_format = a_info->format;
+ config->tensor_media_format = a_info->format;
return res;
}
return _NNS_UINT16;
else if (typestr[4] == '3' && typestr[5] == '2')
return _NNS_UINT32;
+ else if (typestr[4] == '6' && typestr[5] == '4')
+ return _NNS_UINT64;
} else if (len == 5) { /* uint8 */
if (typestr[4] == '8')
return _NNS_UINT8;
return _NNS_INT16;
else if (typestr[3] == '3' && typestr[4] == '2')
return _NNS_INT32;
+ else if (typestr[3] == '6' && typestr[4] == '4')
+ return _NNS_INT64;
} else if (len == 4) { /* int8 */
if (typestr[3] == '8')
return _NNS_INT8;
/**
- * @file unittest_common.cpp
- * @date 31 May 2018
- * @author MyungJoo Ham <myungjoo.ham@samsung.com>
+ * @file unittest_common.cpp
+ * @date 31 May 2018
+ * @author MyungJoo Ham <myungjoo.ham@samsung.com>
+ * @brief Unit test module for NNStreamer common library
+ * @see https://github.com/nnsuite/nnstreamer
+ * @see https://github.sec.samsung.net/STAR/nnstreamer
+ * @bug No known bugs.
*
- * @brief Unit test module for NNStreamer common library
- *
- * Copyright 2018 Samsung Electronics
+ * Copyright (C) 2018 Samsung Electronics Co., Ltd.
*
*/
#include <unistd.h>
#include <tensor_common.h>
-TEST (common_get_tensor_type, int32_1)
+/**
+ * @brief Test for int32 type string.
+ */
+TEST (common_get_tensor_type, int32)
{
EXPECT_EQ (get_tensor_type ("int32"), _NNS_INT32);
-}
-
-TEST (common_get_tensor_type, int32_2)
-{
EXPECT_EQ (get_tensor_type ("INT32"), _NNS_INT32);
-}
-
-TEST (common_get_tensor_type, int32_3)
-{
EXPECT_EQ (get_tensor_type ("iNt32"), _NNS_INT32);
-}
-
-TEST (common_get_tensor_type, int32_4)
-{
EXPECT_EQ (get_tensor_type ("InT32"), _NNS_INT32);
-}
-
-TEST (common_get_tensor_type, int32_5)
-{
EXPECT_EQ (get_tensor_type ("InT322"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, int32_6)
-{
EXPECT_EQ (get_tensor_type ("int3"), _NNS_END);
}
-
-TEST (common_get_tensor_type, int16_1)
+/**
+ * @brief Test for int16 type string.
+ */
+TEST (common_get_tensor_type, int16)
{
EXPECT_EQ (get_tensor_type ("int16"), _NNS_INT16);
-}
-
-TEST (common_get_tensor_type, int16_2)
-{
EXPECT_EQ (get_tensor_type ("INT16"), _NNS_INT16);
-}
-
-TEST (common_get_tensor_type, int16_3)
-{
EXPECT_EQ (get_tensor_type ("iNt16"), _NNS_INT16);
-}
-
-TEST (common_get_tensor_type, int16_4)
-{
EXPECT_EQ (get_tensor_type ("InT16"), _NNS_INT16);
-}
-
-TEST (common_get_tensor_type, int16_5)
-{
EXPECT_EQ (get_tensor_type ("InT162"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, int16_6)
-{
EXPECT_EQ (get_tensor_type ("int1"), _NNS_END);
}
-
-TEST (common_get_tensor_type, int8_1)
+/**
+ * @brief Test for int8 type string.
+ */
+TEST (common_get_tensor_type, int8)
{
EXPECT_EQ (get_tensor_type ("int8"), _NNS_INT8);
-}
-
-TEST (common_get_tensor_type, int8_2)
-{
EXPECT_EQ (get_tensor_type ("INT8"), _NNS_INT8);
-}
-
-TEST (common_get_tensor_type, int8_3)
-{
EXPECT_EQ (get_tensor_type ("iNt8"), _NNS_INT8);
-}
-
-TEST (common_get_tensor_type, int8_4)
-{
EXPECT_EQ (get_tensor_type ("InT8"), _NNS_INT8);
-}
-
-TEST (common_get_tensor_type, int8_5)
-{
EXPECT_EQ (get_tensor_type ("InT82"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, int8_6)
-{
EXPECT_EQ (get_tensor_type ("int3"), _NNS_END);
}
-
-TEST (common_get_tensor_type, uint32_1)
+/**
+ * @brief Test for uint32 type string.
+ */
+TEST (common_get_tensor_type, uint32)
{
EXPECT_EQ (get_tensor_type ("uint32"), _NNS_UINT32);
-}
-
-TEST (common_get_tensor_type, uint32_2)
-{
EXPECT_EQ (get_tensor_type ("UINT32"), _NNS_UINT32);
-}
-
-TEST (common_get_tensor_type, uint32_3)
-{
EXPECT_EQ (get_tensor_type ("uiNt32"), _NNS_UINT32);
-}
-
-TEST (common_get_tensor_type, uint32_4)
-{
EXPECT_EQ (get_tensor_type ("UInT32"), _NNS_UINT32);
-}
-
-TEST (common_get_tensor_type, uint32_5)
-{
EXPECT_EQ (get_tensor_type ("UInT322"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, uint32_6)
-{
EXPECT_EQ (get_tensor_type ("uint3"), _NNS_END);
}
-
-TEST (common_get_tensor_type, uint16_1)
+/**
+ * @brief Test for uint16 type string.
+ */
+TEST (common_get_tensor_type, uint16)
{
EXPECT_EQ (get_tensor_type ("uint16"), _NNS_UINT16);
-}
-
-TEST (common_get_tensor_type, uint16_2)
-{
EXPECT_EQ (get_tensor_type ("UINT16"), _NNS_UINT16);
-}
-
-TEST (common_get_tensor_type, uint16_3)
-{
EXPECT_EQ (get_tensor_type ("uiNt16"), _NNS_UINT16);
-}
-
-TEST (common_get_tensor_type, uint16_4)
-{
EXPECT_EQ (get_tensor_type ("UInT16"), _NNS_UINT16);
-}
-
-TEST (common_get_tensor_type, uint16_5)
-{
EXPECT_EQ (get_tensor_type ("UInT162"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, uint16_6)
-{
EXPECT_EQ (get_tensor_type ("uint1"), _NNS_END);
}
-
-TEST (common_get_tensor_type, uint8_1)
+/**
+ * @brief Test for uint8 type string.
+ */
+TEST (common_get_tensor_type, uint8)
{
EXPECT_EQ (get_tensor_type ("uint8"), _NNS_UINT8);
-}
-
-TEST (common_get_tensor_type, uint8_2)
-{
EXPECT_EQ (get_tensor_type ("UINT8"), _NNS_UINT8);
-}
-
-TEST (common_get_tensor_type, uint8_3)
-{
EXPECT_EQ (get_tensor_type ("uiNt8"), _NNS_UINT8);
-}
-
-TEST (common_get_tensor_type, uint8_4)
-{
EXPECT_EQ (get_tensor_type ("UInT8"), _NNS_UINT8);
-}
-
-TEST (common_get_tensor_type, uint8_5)
-{
EXPECT_EQ (get_tensor_type ("UInT82"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, uint8_6)
-{
EXPECT_EQ (get_tensor_type ("uint3"), _NNS_END);
}
-
-TEST (common_get_tensor_type, float32_1)
+/**
+ * @brief Test for float32 type string.
+ */
+TEST (common_get_tensor_type, float32)
{
EXPECT_EQ (get_tensor_type ("float32"), _NNS_FLOAT32);
-}
-
-TEST (common_get_tensor_type, float32_2)
-{
EXPECT_EQ (get_tensor_type ("FLOAT32"), _NNS_FLOAT32);
-}
-
-TEST (common_get_tensor_type, float32_3)
-{
EXPECT_EQ (get_tensor_type ("float32"), _NNS_FLOAT32);
-}
-
-TEST (common_get_tensor_type, float32_4)
-{
EXPECT_EQ (get_tensor_type ("FloaT32"), _NNS_FLOAT32);
-}
-
-TEST (common_get_tensor_type, float32_5)
-{
EXPECT_EQ (get_tensor_type ("FloaT322"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, float32_6)
-{
EXPECT_EQ (get_tensor_type ("float3"), _NNS_END);
}
-
-
-TEST (common_get_tensor_type, float64_1)
+/**
+ * @brief Test for float64 type string.
+ */
+TEST (common_get_tensor_type, float64)
{
EXPECT_EQ (get_tensor_type ("float64"), _NNS_FLOAT64);
-}
-
-TEST (common_get_tensor_type, float64_2)
-{
EXPECT_EQ (get_tensor_type ("FLOAT64"), _NNS_FLOAT64);
-}
-
-TEST (common_get_tensor_type, float64_3)
-{
EXPECT_EQ (get_tensor_type ("float64"), _NNS_FLOAT64);
-}
-
-TEST (common_get_tensor_type, float64_4)
-{
EXPECT_EQ (get_tensor_type ("FloaT64"), _NNS_FLOAT64);
-}
-
-TEST (common_get_tensor_type, float64_5)
-{
EXPECT_EQ (get_tensor_type ("FloaT642"), _NNS_END);
-}
-
-TEST (common_get_tensor_type, float64_6)
-{
EXPECT_EQ (get_tensor_type ("float6"), _NNS_END);
}
-
-static const gchar *teststrv[] = {
- "abcde",
- "ABCDEF",
- "1234",
- "abcabc",
- "tester",
- NULL
-};
-
-TEST (common_find_key_strv, case1)
+/**
+ * @brief Test for int64 type string.
+ */
+TEST (common_get_tensor_type, int64)
{
- EXPECT_EQ (find_key_strv (teststrv, "abcde"), 0);
+ EXPECT_EQ (get_tensor_type ("int64"), _NNS_INT64);
+ EXPECT_EQ (get_tensor_type ("INT64"), _NNS_INT64);
+ EXPECT_EQ (get_tensor_type ("iNt64"), _NNS_INT64);
+ EXPECT_EQ (get_tensor_type ("InT64"), _NNS_INT64);
+ EXPECT_EQ (get_tensor_type ("InT642"), _NNS_END);
+ EXPECT_EQ (get_tensor_type ("int6"), _NNS_END);
}
-TEST (common_find_key_strv, case2)
+/**
+ * @brief Test for uint64 type string.
+ */
+TEST (common_get_tensor_type, uint64)
{
- EXPECT_EQ (find_key_strv (teststrv, "ABCDE"), 0);
+ EXPECT_EQ (get_tensor_type ("uint64"), _NNS_UINT64);
+ EXPECT_EQ (get_tensor_type ("UINT64"), _NNS_UINT64);
+ EXPECT_EQ (get_tensor_type ("uiNt64"), _NNS_UINT64);
+ EXPECT_EQ (get_tensor_type ("UInT64"), _NNS_UINT64);
+ EXPECT_EQ (get_tensor_type ("UInT642"), _NNS_END);
+ EXPECT_EQ (get_tensor_type ("uint6"), _NNS_END);
}
-TEST (common_find_key_strv, case3)
+/**
+ * @brief Test to find index of the key.
+ */
+TEST (common_find_key_strv, key_index)
{
- EXPECT_EQ (find_key_strv (teststrv, "1234"), 2);
-}
+ const gchar *teststrv[] = {
+ "abcde",
+ "ABCDEF",
+ "1234",
+ "abcabc",
+ "tester",
+ NULL
+ };
-TEST (common_find_key_strv, case4)
-{
+ EXPECT_EQ (find_key_strv (teststrv, "abcde"), 0);
+ EXPECT_EQ (find_key_strv (teststrv, "ABCDE"), 0);
+ EXPECT_EQ (find_key_strv (teststrv, "1234"), 2);
EXPECT_EQ (find_key_strv (teststrv, "tester"), 4);
-}
-
-TEST (common_find_key_strv, case5)
-{
EXPECT_EQ (find_key_strv (teststrv, "abcabcd"), -1);
}
-
+/**
+ * @brief Test for tensor dimension.
+ */
TEST (common_get_tensor_dimension, case1)
{
uint32_t dim[NNS_TENSOR_RANK_LIMIT];
EXPECT_EQ (dim[3], 177);
}
-
+/**
+ * @brief Test for tensor dimension.
+ */
TEST (common_get_tensor_dimension, case2)
{
uint32_t dim[NNS_TENSOR_RANK_LIMIT];
EXPECT_EQ (dim[3], 1);
}
+/**
+ * @brief Test for tensor dimension.
+ */
TEST (common_get_tensor_dimension, case3)
{
uint32_t dim[NNS_TENSOR_RANK_LIMIT];
EXPECT_EQ (dim[3], 1);
}
+/**
+ * @brief Test for tensor dimension.
+ */
TEST (common_get_tensor_dimension, case4)
{
uint32_t dim[NNS_TENSOR_RANK_LIMIT];
EXPECT_EQ (dim[3], 1);
}
+/**
+ * @brief Main function for unit test.
+ */
int
main (int argc, char **argv)
{