[mir] Rename DTYPE to DataType (#6243)
authorСергей Баранников/AI Tools Lab /SRR/Engineer/삼성전자 <s.barannikov@samsung.com>
Mon, 5 Aug 2019 16:35:39 +0000 (19:35 +0300)
committerEfimov Alexander/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Mon, 5 Aug 2019 16:35:39 +0000 (19:35 +0300)
Rename enum class `DTYPE` to `DataType` to conform to the naming rules.

Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
compiler/mir/include/mir/DataType.h
compiler/mir/include/mir/Scalar.h
compiler/mir/include/mir/TensorVariant.h
compiler/mir/src/TensorVariant.cpp
compiler/mir/unittests/TensorVariant.cpp

index 4171724..3799d95 100644 (file)
@@ -20,7 +20,7 @@
 namespace mir
 {
 
-enum class DTYPE
+enum class DataType
 {
   UNKNOWN,
   FLOAT32,
@@ -29,6 +29,9 @@ enum class DTYPE
   INT64
 };
 
+// TODO Remove after chaning all uses.
+using DTYPE = DataType;
+
 } // namespace mir
 
 #endif //_MIR_DATA_TYPE_H_
index a64df9c..ee32bd9 100644 (file)
@@ -34,13 +34,13 @@ public:
   /**
    * @brief Class for Scalar values in modelIR
    * @param data Data pointer
-   * @param dtype Data type
+   * @param data_type Data type
    * @param data_size Data size
    */
-  explicit Scalar(const char *data, DTYPE dtype, unsigned data_size)
+  explicit Scalar(const char *data, DataType data_type, unsigned data_size)
   { // NOLINT(cppcoreguidelines-pro-type-member-init, hicpp-member-init)
     assert(data_size <= _max_scalar_length);
-    _data_type = dtype;
+    _data_type = data_type;
     memcpy(_data, data, data_size);
   }
 
@@ -52,7 +52,7 @@ public:
   /**
    * @return Data type
    */
-  DTYPE getDataType() { return _data_type; }
+  DataType getDataType() { return _data_type; }
 
   /**
    * @return Data size
@@ -61,12 +61,12 @@ public:
   {
     switch (_data_type)
     {
-      case DTYPE::UNKNOWN:
+      case DataType::UNKNOWN:
         return -1;
-      case DTYPE::FLOAT32:
-      case DTYPE::INT32:
+      case DataType::FLOAT32:
+      case DataType::INT32:
         return 4;
-      case DTYPE::INT64:
+      case DataType::INT64:
         return 8;
       default:
         assert(false);
@@ -86,7 +86,7 @@ public:
 
 private:
   static const unsigned int _max_scalar_length = 8;
-  DTYPE _data_type;
+  DataType _data_type;
   char _data[_max_scalar_length];
 };
 
index 31902a3..6f2c59a 100644 (file)
@@ -32,9 +32,9 @@ namespace mir
 class TensorVariant
 {
 public:
-  TensorVariant(DTYPE dtype, const Shape &shape);
+  TensorVariant(DataType data_type, const Shape &shape);
 
-  TensorVariant(DTYPE dtype, const Shape &shape, const void *data);
+  TensorVariant(DataType data_type, const Shape &shape, const void *data);
 
   TensorVariant(const TensorVariant &t_old, const Shape &shape);
 
@@ -58,11 +58,11 @@ public:
   }
 
   const Shape &getShape() const { return _shape; }
-  DTYPE getDataType() const { return _dtype; }
+  DataType getDataType() const { return _data_type; }
   size_t getElementSize() const { return _element_size; }
 
 private:
-  DTYPE _dtype;
+  DataType _data_type;
   std::shared_ptr<char> _data;
   adt::small_vector<int_fast32_t, MAX_DIMENSION_COUNT> _strides;
   Shape _shape;
index c6d63bb..595ae7d 100644 (file)
 namespace mir
 {
 
-TensorVariant::TensorVariant(DTYPE dtype, const Shape &shape)
-    : _dtype(dtype), _strides(shape.rank()), _shape(shape)
+TensorVariant::TensorVariant(DataType data_type, const Shape &shape)
+    : _data_type(data_type), _strides(shape.rank()), _shape(shape)
 {
-  switch (dtype)
+  switch (data_type)
   {
-    case DTYPE::FLOAT32:
+    case DataType::FLOAT32:
       _element_size = sizeof(float);
       break;
-    case DTYPE::FLOAT64:
+    case DataType::FLOAT64:
       _element_size = sizeof(double);
       break;
-    case DTYPE::INT32:
+    case DataType::INT32:
       _element_size = sizeof(int32_t);
       break;
-    case DTYPE::INT64:
+    case DataType::INT64:
       _element_size = sizeof(int64_t);
       break;
     default:
@@ -51,8 +51,8 @@ TensorVariant::TensorVariant(DTYPE dtype, const Shape &shape)
   }
 }
 
-TensorVariant::TensorVariant(DTYPE dtype, const Shape &shape, const void *data)
-    : TensorVariant(dtype, shape)
+TensorVariant::TensorVariant(DataType data_type, const Shape &shape, const void *data)
+    : TensorVariant(data_type, shape)
 {
   std::size_t data_size = _shape.numElements() * _element_size;
   std::memcpy(_data.get(), data, data_size);
@@ -65,7 +65,7 @@ TensorVariant::TensorVariant(DTYPE dtype, const Shape &shape, const void *data)
  * @param shape shape to broadcast to
  */
 TensorVariant::TensorVariant(const TensorVariant &t_old, const Shape &shape)
-    : _dtype(t_old._dtype), _data(t_old._data), _strides(static_cast<size_t>(shape.rank())),
+    : _data_type(t_old._data_type), _data(t_old._data), _strides(static_cast<size_t>(shape.rank())),
       _shape(shape), _element_size(t_old._element_size)
 {
   int axis_old = t_old._shape.rank() - 1;
index e96edfa..7458851 100644 (file)
@@ -23,7 +23,7 @@ using namespace mir;
 TEST(TensorVariant, BasicTest)
 {
   Shape shape{2, 2};
-  TensorVariant t(DTYPE::FLOAT32, shape);
+  TensorVariant t(DataType::FLOAT32, shape);
 
   ASSERT_EQ(t.getShape(), shape);
   ASSERT_EQ(t.getOffset({0, 0}), 0u);
@@ -32,7 +32,7 @@ TEST(TensorVariant, BasicTest)
 TEST(TensorVariant, ElementSizeDeductionTest)
 {
   Shape shape{2, 2, 2};
-  TensorVariant t(DTYPE::FLOAT32, shape);
+  TensorVariant t(DataType::FLOAT32, shape);
 
   ASSERT_EQ(t.getElementSize(), sizeof(float));
   ASSERT_EQ((float *)t.at({1, 1, 1}), (float *)t.at({0, 0, 0}) + 7);