From: 장지섭/On-Device Lab(SR)/Engineer/삼성전자 Date: Fri, 15 Mar 2019 09:53:11 +0000 (+0900) Subject: Introduce boolean types into internal operand (#4759) X-Git-Tag: submit/tizen/20190325.013700~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f44754fd9362a01ff490e8508fa753051560295c;p=platform%2Fcore%2Fml%2Fnnfw.git Introduce boolean types into internal operand (#4759) This commit introduces boolean types into internal operand. Signed-off-by: jiseob.jang --- diff --git a/runtimes/neurun/src/backend/acl_cl/Convert.cc b/runtimes/neurun/src/backend/acl_cl/Convert.cc index 9a95f6f..7778da9 100644 --- a/runtimes/neurun/src/backend/acl_cl/Convert.cc +++ b/runtimes/neurun/src/backend/acl_cl/Convert.cc @@ -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; diff --git a/runtimes/neurun/src/backend/cpu/kernel/OperationUtils.cc b/runtimes/neurun/src/backend/cpu/kernel/OperationUtils.cc index 0c696a2..c01770a 100644 --- a/runtimes/neurun/src/backend/cpu/kernel/OperationUtils.cc +++ b/runtimes/neurun/src/backend/cpu/kernel/OperationUtils.cc @@ -211,6 +211,8 @@ uint32_t sizeOfData(OperandType type, const std::vector &dimensions) case OperandType::TENSOR_INT32: size = 4; break; + case OperandType::SCALAR_BOOL: + case OperandType::TENSOR_BOOL8: case OperandType::TENSOR_QUANT8_ASYMM: size = 1; break; diff --git a/runtimes/neurun/src/compiler/ConstantInitializer.cc b/runtimes/neurun/src/compiler/ConstantInitializer.cc index a19021e..bdc9f23 100644 --- a/runtimes/neurun/src/compiler/ConstantInitializer.cc +++ b/runtimes/neurun/src/compiler/ConstantInitializer.cc @@ -194,6 +194,8 @@ void ConstantInitializer::operator()() case DataType::SCALAR_UINT32: run(ind, obj, model_obj); break; + case DataType::SCALAR_BOOL: + case DataType::TENSOR_BOOL8: case DataType::TENSOR_QUANT8_ASYMM: run(ind, obj, model_obj); break; diff --git a/runtimes/neurun/src/exec/ExecutorBase.cc b/runtimes/neurun/src/exec/ExecutorBase.cc index db982a8..9c18a83 100644 --- a/runtimes/neurun/src/exec/ExecutorBase.cc +++ b/runtimes/neurun/src/exec/ExecutorBase.cc @@ -50,6 +50,8 @@ void ExecutorBase::setInput(const model::operand::IO::Index &index, case DataType::SCALAR_UINT32: source(index, buffer, length); break; + case DataType::SCALAR_BOOL: + case DataType::TENSOR_BOOL8: case DataType::TENSOR_QUANT8_ASYMM: source(index, buffer, length); break; @@ -77,6 +79,8 @@ void ExecutorBase::setOutput(const model::operand::IO::Index &index, case DataType::SCALAR_UINT32: sink(index, buffer, length); break; + case DataType::SCALAR_BOOL: + case DataType::TENSOR_BOOL8: case DataType::TENSOR_QUANT8_ASYMM: sink(index, buffer, length); break; diff --git a/runtimes/neurun/src/exec/interp/Interpreter.cc b/runtimes/neurun/src/exec/interp/Interpreter.cc index f1d207b..ab28caf 100644 --- a/runtimes/neurun/src/exec/interp/Interpreter.cc +++ b/runtimes/neurun/src/exec/interp/Interpreter.cc @@ -42,6 +42,8 @@ void Interpreter::setInput(const neurun::model::operand::IO::Index &index, case DataType::SCALAR_UINT32: source>(index, reinterpret_cast(buffer), length); break; + case DataType::SCALAR_BOOL: + case DataType::TENSOR_BOOL8: case DataType::TENSOR_QUANT8_ASYMM: source>(index, reinterpret_cast(buffer), length); break; @@ -73,6 +75,8 @@ void Interpreter::setOutput(const neurun::model::operand::IO::Index &index, case DataType::SCALAR_UINT32: sink>(index, reinterpret_cast(buffer), length); break; + case DataType::SCALAR_BOOL: + case DataType::TENSOR_BOOL8: case DataType::TENSOR_QUANT8_ASYMM: sink>(index, reinterpret_cast(buffer), length); break; diff --git a/runtimes/neurun/src/model/operand/DataType.h b/runtimes/neurun/src/model/operand/DataType.h index f88d9d9..138b8f0 100644 --- a/runtimes/neurun/src/model/operand/DataType.h +++ b/runtimes/neurun/src/model/operand/DataType.h @@ -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: