From 2a0101203ff67ea9c7d5acc27b18f82c500f6715 Mon Sep 17 00:00:00 2001 From: "Michael K. Sanders" Date: Wed, 28 Nov 2018 10:35:08 +0000 Subject: [PATCH 1/3] Fixes VTS test failures. Moves comments for type range values into their enums to make it harder to forget to update them. Adds missing float16 types for ARGMAX/ARGMIN/CAST. Test: VtsHalNeuralnetworksV1_2TargetTest --hal_service_instance=android.hardware.neuralnetworks@1.2::IDevice/sample-all Test: [ PASSED ] 2519 tests. Change-Id: Ic7c3df8c8fbff45fe497f304b6b2c7a09e7dc5a6 Merged-In: Ic7c3df8c8fbff45fe497f304b6b2c7a09e7dc5a6 (cherry picked from commit bbdab2feee37c7bc07ce8445d936beea1549370f) --- neuralnetworks/1.2/types.hal | 20 +++++++++++++------ .../1.2/vts/functional/ValidateModel.cpp | 9 +++++---- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal index a1a1bad577..f196792f8b 100644 --- a/neuralnetworks/1.2/types.hal +++ b/neuralnetworks/1.2/types.hal @@ -49,12 +49,16 @@ enum OperandType : @1.0::OperandType { * represents false; any other value represents true. */ TENSOR_BOOL8 = 9, + /* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF + * OperandTypeRange::OPERAND_FUNDAMENTAL_MAX. + */ + /* ADDING A NEW OEM TYPE REQUIRES UPDATING THE VALUE OF + * OperandTypeRange::OPERAND_OEM_MAX. + */ }; /** - * The range of values in the OperandType enum. - * - * THE MAX VALUES MUST BE UPDATED WHEN ADDING NEW TYPES to the OperandType enum. + * The range of operand values in the OperandType enum. */ enum OperandTypeRange : uint32_t { OPERAND_FUNDAMENTAL_MIN = 0, @@ -122,16 +126,20 @@ enum OperationType : @1.1::OperationType { ROTATED_BBOX_TRANSFORM = 87, ABS = 88, ROI_POOLING = 89, + /* ADDING A NEW FUNDAMENTAL OPERATION REQUIRES UPDATING THE VALUE OF + * OperationTypeRange::OPERATION_FUNDAMENTAL_MAX. + */ + /* ADDING A NEW OEM OPERATION REQUIRES UPDATING THE VALUE OF + * OperationTypeRange::OPERATION_OEM_MAX. + */ }; /** * The range of values in the OperationType enum. - * - * THE MAX VALUES MUST BE UPDATED WHEN ADDING NEW TYPES to the OperationType enum. */ enum OperationTypeRange : uint32_t { OPERATION_FUNDAMENTAL_MIN = 0, - OPERATION_FUNDAMENTAL_MAX = 87, + OPERATION_FUNDAMENTAL_MAX = 89, OPERATION_OEM_MIN = 10000, OPERATION_OEM_MAX = 10000, }; diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp index 802499287a..7a9edf42a1 100644 --- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp @@ -300,8 +300,9 @@ static bool mutateOperationOperandTypeSkip(size_t operand, OperandType type, con for (const Operation& operation : model.operations) { // Skip mutateOperationOperandTypeTest for the following operations. // - LSH_PROJECTION's second argument is allowed to have any type. - // - ARGMIN and ARGMAX's first argument can be any of TENSOR_(FLOAT32|INT32|QUANT8_ASYMM). - // - CAST's argument can be any of TENSOR_(FLOAT32|INT32|QUANT8_ASYMM). + // - ARGMIN and ARGMAX's first argument can be any of + // TENSOR_(FLOAT16|FLOAT32|INT32|QUANT8_ASYMM). + // - CAST's argument can be any of TENSOR_(FLOAT16|FLOAT32|INT32|QUANT8_ASYMM). switch (operation.type) { case OperationType::LSH_PROJECTION: { if (operand == operation.inputs[1]) { @@ -311,8 +312,8 @@ static bool mutateOperationOperandTypeSkip(size_t operand, OperandType type, con case OperationType::CAST: case OperationType::ARGMAX: case OperationType::ARGMIN: { - if (type == OperandType::TENSOR_FLOAT32 || type == OperandType::TENSOR_INT32 || - type == OperandType::TENSOR_QUANT8_ASYMM) { + if (type == OperandType::TENSOR_FLOAT16 || type == OperandType::TENSOR_FLOAT32 || + type == OperandType::TENSOR_INT32 || type == OperandType::TENSOR_QUANT8_ASYMM) { return true; } } break; From a26349a847af072e53e58126dddf7538e0914d13 Mon Sep 17 00:00:00 2001 From: Lev Proleev Date: Wed, 5 Dec 2018 10:38:59 +0000 Subject: [PATCH 2/3] Add two missing comparison ops to HAL Bug: 113561733 Test: NeuralNetworksTest_static Test: VtsHalNeuralnetworksV1_2TargetTest Change-Id: Ied32f217f4e4ece3c082f6485f99cf8dee78e55f Merged-In: Ied32f217f4e4ece3c082f6485f99cf8dee78e55f (cherry picked from commit 149f2b018bd9d8feb2fe4e93f81e19ec03dc57a7) --- neuralnetworks/1.2/types.hal | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal index f196792f8b..45476eec3d 100644 --- a/neuralnetworks/1.2/types.hal +++ b/neuralnetworks/1.2/types.hal @@ -126,6 +126,8 @@ enum OperationType : @1.1::OperationType { ROTATED_BBOX_TRANSFORM = 87, ABS = 88, ROI_POOLING = 89, + EQUAL = 90, + NOT_EQUAL = 91, /* ADDING A NEW FUNDAMENTAL OPERATION REQUIRES UPDATING THE VALUE OF * OperationTypeRange::OPERATION_FUNDAMENTAL_MAX. */ @@ -139,7 +141,7 @@ enum OperationType : @1.1::OperationType { */ enum OperationTypeRange : uint32_t { OPERATION_FUNDAMENTAL_MIN = 0, - OPERATION_FUNDAMENTAL_MAX = 89, + OPERATION_FUNDAMENTAL_MAX = 91, OPERATION_OEM_MIN = 10000, OPERATION_OEM_MAX = 10000, }; From 5666626b337bf86fbf2b5e626a0f8e5d1017a499 Mon Sep 17 00:00:00 2001 From: Xusong Wang Date: Wed, 5 Dec 2018 14:21:51 -0800 Subject: [PATCH 3/3] Add new OperandType FLOAT16. Bug: 120225191 Test: NeuralNetworksTest_static Test: VtsHalNeuralnetworksV1_2TargetTest Change-Id: Iaabebe490303c9c93a34d319c8c594df13fb7899 Merged-In: Iaabebe490303c9c93a34d319c8c594df13fb7899 (cherry picked from commit 7bca34bee702be0aac9f56b11ee9975f3ce08dd9) --- neuralnetworks/1.2/types.hal | 6 ++++-- neuralnetworks/1.2/vts/functional/ValidateModel.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal index 45476eec3d..4ab0c24ed8 100644 --- a/neuralnetworks/1.2/types.hal +++ b/neuralnetworks/1.2/types.hal @@ -40,7 +40,7 @@ enum OperandType : @1.0::OperandType { * scale is a 32 bit floating point with value greater then zero. */ TENSOR_QUANT16_SYMM = 7, - /** A tensor of 16 bit floating point values. */ + /** A tensor of IEEE 754 16 bit floating point values. */ TENSOR_FLOAT16 = 8, /** * A tensor of 8 bit boolean values. @@ -49,6 +49,8 @@ enum OperandType : @1.0::OperandType { * represents false; any other value represents true. */ TENSOR_BOOL8 = 9, + /** An IEEE 754 16 bit floating point scalar value. */ + FLOAT16 = 10, /* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF * OperandTypeRange::OPERAND_FUNDAMENTAL_MAX. */ @@ -62,7 +64,7 @@ enum OperandType : @1.0::OperandType { */ enum OperandTypeRange : uint32_t { OPERAND_FUNDAMENTAL_MIN = 0, - OPERAND_FUNDAMENTAL_MAX = 9, + OPERAND_FUNDAMENTAL_MAX = 10, OPERAND_OEM_MIN = 10000, OPERAND_OEM_MAX = 10001, }; diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp index 7a9edf42a1..8f6d54f7f9 100644 --- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp @@ -151,6 +151,7 @@ static void mutateOperandTypeTest(const sp& device, const Model& model) static uint32_t getInvalidRank(OperandType type) { switch (type) { + case OperandType::FLOAT16: case OperandType::FLOAT32: case OperandType::INT32: case OperandType::UINT32: @@ -182,6 +183,7 @@ static void mutateOperandRankTest(const sp& device, const Model& model) static float getInvalidScale(OperandType type) { switch (type) { + case OperandType::FLOAT16: case OperandType::FLOAT32: case OperandType::INT32: case OperandType::UINT32: @@ -214,6 +216,7 @@ static void mutateOperandScaleTest(const sp& device, const Model& model static std::vector getInvalidZeroPoints(OperandType type) { switch (type) { + case OperandType::FLOAT16: case OperandType::FLOAT32: case OperandType::INT32: case OperandType::UINT32: @@ -257,6 +260,7 @@ static void mutateOperand(Operand* operand, OperandType type) { Operand newOperand = *operand; newOperand.type = type; switch (type) { + case OperandType::FLOAT16: case OperandType::FLOAT32: case OperandType::INT32: case OperandType::UINT32: