Introduce boolean types into internal operand (#4759)
author장지섭/On-Device Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Fri, 15 Mar 2019 09:53:11 +0000 (18:53 +0900)
committer박세희/On-Device Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Fri, 15 Mar 2019 09:53:11 +0000 (18:53 +0900)
This commit introduces boolean types into internal operand.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
runtimes/neurun/src/backend/acl_cl/Convert.cc
runtimes/neurun/src/backend/cpu/kernel/OperationUtils.cc
runtimes/neurun/src/compiler/ConstantInitializer.cc
runtimes/neurun/src/exec/ExecutorBase.cc
runtimes/neurun/src/exec/interp/Interpreter.cc
runtimes/neurun/src/model/operand/DataType.h

index 9a95f6f..7778da9 100644 (file)
@@ -64,6 +64,9 @@ namespace acl_cl
       return ::arm_compute::DataType::U32;
     case ::neurun::model::operand::DataType::TENSOR_QUANT8_ASYMM:
       return ::arm_compute::DataType::QASYMM8;
+    case ::neurun::model::operand::DataType::SCALAR_BOOL:
+    case ::neurun::model::operand::DataType::TENSOR_BOOL8:
+      return ::arm_compute::DataType::U8;
     default:
       throw std::runtime_error("Not supported, yet");
       break;
index 0c696a2..c01770a 100644 (file)
@@ -211,6 +211,8 @@ uint32_t sizeOfData(OperandType type, const std::vector<uint32_t> &dimensions)
     case OperandType::TENSOR_INT32:
       size = 4;
       break;
+    case OperandType::SCALAR_BOOL:
+    case OperandType::TENSOR_BOOL8:
     case OperandType::TENSOR_QUANT8_ASYMM:
       size = 1;
       break;
index a19021e..bdc9f23 100644 (file)
@@ -194,6 +194,8 @@ void ConstantInitializer::operator()()
       case DataType::SCALAR_UINT32:
         run<uint32_t>(ind, obj, model_obj);
         break;
+      case DataType::SCALAR_BOOL:
+      case DataType::TENSOR_BOOL8:
       case DataType::TENSOR_QUANT8_ASYMM:
         run<uint8_t>(ind, obj, model_obj);
         break;
index db982a8..9c18a83 100644 (file)
@@ -50,6 +50,8 @@ void ExecutorBase::setInput(const model::operand::IO::Index &index,
     case DataType::SCALAR_UINT32:
       source<uint32_t>(index, buffer, length);
       break;
+    case DataType::SCALAR_BOOL:
+    case DataType::TENSOR_BOOL8:
     case DataType::TENSOR_QUANT8_ASYMM:
       source<uint8_t>(index, buffer, length);
       break;
@@ -77,6 +79,8 @@ void ExecutorBase::setOutput(const model::operand::IO::Index &index,
     case DataType::SCALAR_UINT32:
       sink<uint32_t>(index, buffer, length);
       break;
+    case DataType::SCALAR_BOOL:
+    case DataType::TENSOR_BOOL8:
     case DataType::TENSOR_QUANT8_ASYMM:
       sink<uint8_t>(index, buffer, length);
       break;
index f1d207b..ab28caf 100644 (file)
@@ -42,6 +42,8 @@ void Interpreter::setInput(const neurun::model::operand::IO::Index &index,
     case DataType::SCALAR_UINT32:
       source<Source<uint32_t>>(index, reinterpret_cast<const uint32_t *>(buffer), length);
       break;
+    case DataType::SCALAR_BOOL:
+    case DataType::TENSOR_BOOL8:
     case DataType::TENSOR_QUANT8_ASYMM:
       source<Source<uint8_t>>(index, reinterpret_cast<const uint8_t *>(buffer), length);
       break;
@@ -73,6 +75,8 @@ void Interpreter::setOutput(const neurun::model::operand::IO::Index &index,
     case DataType::SCALAR_UINT32:
       sink<Sink<uint32_t>>(index, reinterpret_cast<uint32_t *>(buffer), length);
       break;
+    case DataType::SCALAR_BOOL:
+    case DataType::TENSOR_BOOL8:
     case DataType::TENSOR_QUANT8_ASYMM:
       sink<Sink<uint8_t>>(index, reinterpret_cast<uint8_t *>(buffer), length);
       break;
index f88d9d9..138b8f0 100644 (file)
@@ -36,6 +36,8 @@ enum class DataType
   TENSOR_INT32 = 4,
 
   TENSOR_QUANT8_ASYMM = 5,
+  SCALAR_BOOL = 6,
+  TENSOR_BOOL8 = 7,
 };
 
 inline size_t sizeOfDataType(DataType data_type)
@@ -50,6 +52,8 @@ inline size_t sizeOfDataType(DataType data_type)
       return sizeof(int32_t);
     case DataType::SCALAR_UINT32:
       return sizeof(uint32_t);
+    case DataType::SCALAR_BOOL:
+    case DataType::TENSOR_BOOL8:
     case DataType::TENSOR_QUANT8_ASYMM:
       return sizeof(uint8_t);
     default: