summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Shklyaev <slavash@google.com>2019-09-30 16:04:43 +0100
committerSlava Shklyaev <slavash@google.com>2019-10-01 15:02:59 +0100
commit432890eef10707c60ba118f6c35c9a0c8576ed1f (patch)
tree204421f3d65d18919077cd2e66c0e46bf3e61844
parent8ae9b388e09071fe247eafde994af38eb0b16a48 (diff)
downloadml-432890eef10707c60ba118f6c35c9a0c8576ed1f.tar.gz
Improve validateHalVersion error message
This change replaces the following error message: OperationsUtils: NN_RET_CHECK failed (frameworks/ml/nn/common/OperationsUtils.cpp:80): The given inputs and outputs are only supported in HAL version 1.3 and later (validating using HAL version 1.2) with OperationsUtils: NN_RET_CHECK failed (frameworks/ml/nn/common/OperationsUtils.cpp:81): Operation IDENTITY with inputs {BOOL} and outputs {BOOL} is only supported since HAL version 1.3 (validating using HAL version 1.2) The new message provides information what operation is being validated and what its input and output types are. Note that the new message is imprecise if we reject based on operand shapes or extraParams. Fix: 141852946 Bug: 139181916 Test: NeuralNetworksTest_static Change-Id: I8b001f40cddc93648d7f04768aa3e92f4a7081fd Merged-In: I8b001f40cddc93648d7f04768aa3e92f4a7081fd (cherry picked from commit 64e2d32aecbb3e3edf5e4b66a39f93d28025889e)
-rw-r--r--nn/common/OperationsUtils.cpp22
-rw-r--r--nn/common/Utils.cpp19
-rw-r--r--nn/common/include/OperationsUtils.h2
3 files changed, 35 insertions, 8 deletions
diff --git a/nn/common/OperationsUtils.cpp b/nn/common/OperationsUtils.cpp
index cec15fc94..5c50e3deb 100644
--- a/nn/common/OperationsUtils.cpp
+++ b/nn/common/OperationsUtils.cpp
@@ -21,6 +21,7 @@
#include "Utils.h"
#include <cmath>
+#include <sstream>
namespace android {
namespace nn {
@@ -60,9 +61,24 @@ bool validateOutputTypes(const IOperationValidationContext* context,
bool validateHalVersion(const IOperationValidationContext* context,
HalVersion minSupportedHalVersion) {
if (context->getHalVersion() < minSupportedHalVersion) {
- NN_RET_CHECK_FAIL() << "The given inputs and outputs are only supported in "
- << toString(minSupportedHalVersion) << " and later (validating using "
- << toString(context->getHalVersion()) << ")";
+ std::ostringstream message;
+ message << "Operation " << context->getOperationName() << " with inputs {";
+ for (uint32_t i = 0, n = context->getNumInputs(); i < n; ++i) {
+ if (i != 0) {
+ message << ", ";
+ }
+ message << toString(context->getInputType(i));
+ }
+ message << "} and outputs {";
+ for (uint32_t i = 0, n = context->getNumOutputs(); i < n; ++i) {
+ if (i != 0) {
+ message << ", ";
+ }
+ message << toString(context->getOutputType(i));
+ }
+ message << "} is only supported since " << toString(minSupportedHalVersion)
+ << " (validating using " << toString(context->getHalVersion()) << ")";
+ NN_RET_CHECK_FAIL() << message.str();
}
return true;
}
diff --git a/nn/common/Utils.cpp b/nn/common/Utils.cpp
index 26cadc84c..0b46d5ee7 100644
--- a/nn/common/Utils.cpp
+++ b/nn/common/Utils.cpp
@@ -117,16 +117,19 @@ class OperationValidationContext : public IOperationValidationContext {
DISALLOW_IMPLICIT_CONSTRUCTORS(OperationValidationContext);
public:
- OperationValidationContext(uint32_t inputCount, const uint32_t* inputIndexes,
- uint32_t outputCount, const uint32_t* outputIndexes,
- const Operand* operands, HalVersion halVersion)
- : inputCount(inputCount),
+ OperationValidationContext(const char* operationName, uint32_t inputCount,
+ const uint32_t* inputIndexes, uint32_t outputCount,
+ const uint32_t* outputIndexes, const Operand* operands,
+ HalVersion halVersion)
+ : operationName(operationName),
+ inputCount(inputCount),
inputIndexes(inputIndexes),
outputCount(outputCount),
outputIndexes(outputIndexes),
operands(operands),
halVersion(halVersion) {}
+ const char* getOperationName() const override;
HalVersion getHalVersion() const override;
uint32_t getNumInputs() const override;
@@ -142,6 +145,7 @@ class OperationValidationContext : public IOperationValidationContext {
const Operand* getInputOperand(uint32_t index) const;
const Operand* getOutputOperand(uint32_t index) const;
+ const char* operationName;
uint32_t inputCount;
const uint32_t* inputIndexes;
uint32_t outputCount;
@@ -150,6 +154,10 @@ class OperationValidationContext : public IOperationValidationContext {
HalVersion halVersion;
};
+const char* OperationValidationContext::getOperationName() const {
+ return operationName;
+}
+
HalVersion OperationValidationContext::getHalVersion() const {
return halVersion;
}
@@ -1675,7 +1683,8 @@ int validateOperation(ANeuralNetworksOperationType opType, uint32_t inputCount,
LOG(ERROR) << "Incomplete operation registration: " << getOperationName(opType);
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
- OperationValidationContext context(inputCount, inputIndexes, outputCount, outputIndexes,
+ OperationValidationContext context(operationRegistration->name, inputCount,
+ inputIndexes, outputCount, outputIndexes,
operands.data(), halVersion);
if (!operationRegistration->validate(&context)) {
LOG(ERROR) << "Validation failed for operation " << getOperationName(opType);
diff --git a/nn/common/include/OperationsUtils.h b/nn/common/include/OperationsUtils.h
index 9ae3aca8b..8b2b66c2e 100644
--- a/nn/common/include/OperationsUtils.h
+++ b/nn/common/include/OperationsUtils.h
@@ -56,6 +56,8 @@ class IOperationValidationContext {
public:
virtual ~IOperationValidationContext() {}
+ virtual const char* getOperationName() const = 0;
+
// The HAL version of the environment in which the operation is to be
// executed.
//