[Common] Provide union of tensor elements.
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 14 Nov 2018 12:22:41 +0000 (21:22 +0900)
committerjaeyun-jung <39614140+jaeyun-jung@users.noreply.github.com>
Sat, 17 Nov 2018 05:37:42 +0000 (14:37 +0900)
This makes C++ template-like usage of tensor elements EASIER.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
gst/nnstreamer/tensor_typedef.h

index cc11d71..d37ced1 100644 (file)
@@ -70,9 +70,27 @@ static const unsigned int tensor_element_size[] = {
   [_NNS_FLOAT32] = 4,
   [_NNS_INT64] = 8,
   [_NNS_UINT64] = 8,
+
+  [_NNS_END] = 0,
 };
 
 /**
+ * @brief To make the code simple with all the types. "C++ Template"-like.
+ */
+typedef union {
+  int32_t _int32_t;
+  uint32_t _uint32_t;
+  int16_t _int16_t;
+  uint16_t _uint16_t;
+  int8_t _int8_t;
+  uint8_t _uint8_t;
+  double _double;
+  float _float;
+  int64_t _int64_t;
+  uint64_t _uint64_t;
+} tensor_element;
+
+/**
  * @brief NN Frameworks available for the tensor_filter element.
  */
 typedef enum _nnfw_type