From 19d63453d4c2723c3fad4ce7f852f548d761278e Mon Sep 17 00:00:00 2001 From: "Michael K. Sanders" Date: Fri, 12 Oct 2018 09:10:15 +0100 Subject: [PATCH] Adds TENSOR_FLOAT16 operand type. Bug: 113563458 Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all Change-Id: If12ceff428e1b1a90ef99b7353f0df60d4ef8010 --- neuralnetworks/1.2/types.hal | 2 ++ neuralnetworks/1.2/vts/functional/ValidateModel.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal index 0aa7cc204b..4a1e7a8a40 100644 --- a/neuralnetworks/1.2/types.hal +++ b/neuralnetworks/1.2/types.hal @@ -42,6 +42,8 @@ enum OperandType : @1.0::OperandType { * realValue = (integerValue - zeroPoint) * scale. */ TENSOR_QUANT16_ASYMM = 7, + /** A tensor of 16 bit floating point values. */ + TENSOR_FLOAT16 = 8, }; /** diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp index 9af6258917..b840199d43 100644 --- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp @@ -157,6 +157,7 @@ static uint32_t getInvalidRank(OperandType type) { case OperandType::UINT32: case OperandType::BOOL: return 1; + case OperandType::TENSOR_FLOAT16: case OperandType::TENSOR_FLOAT32: case OperandType::TENSOR_INT32: case OperandType::TENSOR_QUANT8_ASYMM: @@ -186,6 +187,7 @@ static float getInvalidScale(OperandType type) { case OperandType::INT32: case OperandType::UINT32: case OperandType::BOOL: + case OperandType::TENSOR_FLOAT16: case OperandType::TENSOR_FLOAT32: return 1.0f; case OperandType::TENSOR_INT32: @@ -217,6 +219,7 @@ static std::vector getInvalidZeroPoints(OperandType type) { case OperandType::INT32: case OperandType::UINT32: case OperandType::BOOL: + case OperandType::TENSOR_FLOAT16: case OperandType::TENSOR_FLOAT32: case OperandType::TENSOR_INT32: return {1}; @@ -262,6 +265,7 @@ static void mutateOperand(Operand* operand, OperandType type) { newOperand.scale = 0.0f; newOperand.zeroPoint = 0; break; + case OperandType::TENSOR_FLOAT16: case OperandType::TENSOR_FLOAT32: newOperand.dimensions = operand->dimensions.size() > 0 ? operand->dimensions : hidl_vec({1});