From ec1e5b8d0a0eeba7eae0f1fdb5e32c72f8a8093c Mon Sep 17 00:00:00 2001 From: Kevin May Date: Wed, 26 Feb 2020 17:00:39 +0000 Subject: IVGCVSW-4473 Android R pre Hal 1_3 build changes * Update ErrorStatus to V1_0::ErrorStatus * Update Request to V1_0::Request * Update OperandType to V1_2::OperandType * Add namespace android::nn::hal in ArmnnDriverImpl for R only * Add missing g_RelaxedFloat32toFloat16PerformancePowerUsageName * Add namespace V1_0 or V1_1 where necessary * Update Android.mk with R macro and android.hardware.neuralnetworks@1.3 * Remove androidnn.go * include IAllocator in DriverTestHelpers * Remove unused LOCAL_CFLAGS Signed-off-by: Kevin May Change-Id: I1787f1ed6784b3bbec017536d87d49197405e853 Signed-off-by: Kevin May --- 1.2/ArmnnDriverImpl.cpp | 85 +++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 38 deletions(-) (limited to '1.2/ArmnnDriverImpl.cpp') diff --git a/1.2/ArmnnDriverImpl.cpp b/1.2/ArmnnDriverImpl.cpp index 691156fa..bfa730b5 100644 --- a/1.2/ArmnnDriverImpl.cpp +++ b/1.2/ArmnnDriverImpl.cpp @@ -57,7 +57,7 @@ const char *g_OperandTypeInt32PerformancePowerUsage = "Armnn.operandType void NotifyCallbackAndCheck(const sp& callback, - ErrorStatus errorStatus, + V1_0::ErrorStatus errorStatus, const sp& preparedModelPtr) { Return returned = callback->notify_1_2(errorStatus, preparedModelPtr); @@ -69,9 +69,9 @@ void NotifyCallbackAndCheck(const sp& callback, } } -Return FailPrepareModel(ErrorStatus error, - const std::string& message, - const sp& callback) +Return FailPrepareModel(V1_0::ErrorStatus error, + const std::string& message, + const sp& callback) { ALOGW("ArmnnDriverImpl::prepareModel: %s", message.c_str()); NotifyCallbackAndCheck(callback, error, nullptr); @@ -85,29 +85,30 @@ namespace armnn_driver namespace hal_1_2 { -Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntimePtr& runtime, - const armnn::IGpuAccTunedParametersPtr& clTunedParameters, - const DriverOptions& options, - const V1_2::Model& model, - const sp& cb, - bool float32ToFloat16) +Return ArmnnDriverImpl::prepareArmnnModel_1_2( + const armnn::IRuntimePtr& runtime, + const armnn::IGpuAccTunedParametersPtr& clTunedParameters, + const DriverOptions& options, + const V1_2::Model& model, + const sp& cb, + bool float32ToFloat16) { ALOGV("ArmnnDriverImpl::prepareArmnnModel_1_2()"); if (cb.get() == nullptr) { ALOGW("ArmnnDriverImpl::prepareModel: Invalid callback passed to prepareModel"); - return ErrorStatus::INVALID_ARGUMENT; + return V1_0::ErrorStatus::INVALID_ARGUMENT; } if (!runtime) { - return FailPrepareModel(ErrorStatus::DEVICE_UNAVAILABLE, "Device unavailable", cb); + return FailPrepareModel(V1_0::ErrorStatus::DEVICE_UNAVAILABLE, "Device unavailable", cb); } if (!android::nn::validateModel(model)) { - return FailPrepareModel(ErrorStatus::INVALID_ARGUMENT, "Invalid model passed as input", cb); + return FailPrepareModel(V1_0::ErrorStatus::INVALID_ARGUMENT, "Invalid model passed as input", cb); } // Deliberately ignore any unsupported operations requested by the options - @@ -120,8 +121,8 @@ Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntime if (modelConverter.GetConversionResult() != ConversionResult::Success) { - FailPrepareModel(ErrorStatus::GENERAL_FAILURE, "ModelToINetworkConverter failed", cb); - return ErrorStatus::NONE; + FailPrepareModel(V1_0::ErrorStatus::GENERAL_FAILURE, "ModelToINetworkConverter failed", cb); + return V1_0::ErrorStatus::NONE; } // Optimize the network @@ -142,8 +143,8 @@ Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntime { std::stringstream message; message << "Exception (" << e.what() << ") caught from optimize."; - FailPrepareModel(ErrorStatus::GENERAL_FAILURE, message.str(), cb); - return ErrorStatus::NONE; + FailPrepareModel(V1_0::ErrorStatus::GENERAL_FAILURE, message.str(), cb); + return V1_0::ErrorStatus::NONE; } // Check that the optimized network is valid. @@ -155,8 +156,8 @@ Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntime { message << "\n" << msg; } - FailPrepareModel(ErrorStatus::GENERAL_FAILURE, message.str(), cb); - return ErrorStatus::NONE; + FailPrepareModel(V1_0::ErrorStatus::GENERAL_FAILURE, message.str(), cb); + return V1_0::ErrorStatus::NONE; } // Export the optimized network graph to a dot file if an output dump directory @@ -170,15 +171,15 @@ Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntime { if (runtime->LoadNetwork(netId, move(optNet)) != armnn::Status::Success) { - return FailPrepareModel(ErrorStatus::GENERAL_FAILURE, "Network could not be loaded", cb); + return FailPrepareModel(V1_0::ErrorStatus::GENERAL_FAILURE, "Network could not be loaded", cb); } } catch (std::exception& e) { std::stringstream message; message << "Exception (" << e.what()<< ") caught from LoadNetwork."; - FailPrepareModel(ErrorStatus::GENERAL_FAILURE, message.str(), cb); - return ErrorStatus::NONE; + FailPrepareModel(V1_0::ErrorStatus::GENERAL_FAILURE, message.str(), cb); + return V1_0::ErrorStatus::NONE; } // Now that we have a networkId for the graph rename the dump file to use it @@ -199,7 +200,7 @@ Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntime // this is enabled) before the first 'real' inference which removes the overhead of the first inference. if (!preparedModel->ExecuteWithDummyInputs()) { - return FailPrepareModel(ErrorStatus::GENERAL_FAILURE, "Network could not be executed", cb); + return FailPrepareModel(V1_0::ErrorStatus::GENERAL_FAILURE, "Network could not be executed", cb); } if (clTunedParameters && @@ -217,9 +218,9 @@ Return ArmnnDriverImpl::prepareArmnnModel_1_2(const armnn::IRuntime } } - NotifyCallbackAndCheck(cb, ErrorStatus::NONE, preparedModel.release()); + NotifyCallbackAndCheck(cb, V1_0::ErrorStatus::NONE, preparedModel.release()); - return ErrorStatus::NONE; + return V1_0::ErrorStatus::NONE; } Return ArmnnDriverImpl::getCapabilities_1_2(const armnn::IRuntimePtr& runtime, @@ -240,52 +241,56 @@ Return ArmnnDriverImpl::getCapabilities_1_2(const armnn::IRuntimePtr& runt ParseSystemProperty(g_RelaxedFloat32toFloat16PerformancePowerUsage, defaultValue); // Set the base value for all operand types + #ifdef ARMNN_ANDROID_R + capabilities.operandPerformance = nonExtensionOperandPerformance({FLT_MAX, FLT_MAX}); + #else capabilities.operandPerformance = nonExtensionOperandPerformance({FLT_MAX, FLT_MAX}); + #endif // Load supported operand types - update(&capabilities.operandPerformance, OperandType::TENSOR_FLOAT32, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_FLOAT32, { .execTime = ParseSystemProperty(g_OperandTypeTensorFloat32PerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeTensorFloat32PerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::FLOAT32, + update(&capabilities.operandPerformance, V1_2::OperandType::FLOAT32, { .execTime = ParseSystemProperty(g_OperandTypeFloat32PerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeFloat32PerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::TENSOR_FLOAT16, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_FLOAT16, { .execTime = ParseSystemProperty(g_OperandTypeTensorFloat16PerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeTensorFloat16PerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::FLOAT16, + update(&capabilities.operandPerformance, V1_2::OperandType::FLOAT16, { .execTime = ParseSystemProperty(g_OperandTypeFloat16PerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeFloat16PerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::TENSOR_QUANT8_ASYMM, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_QUANT8_ASYMM, { .execTime = ParseSystemProperty(g_OperandTypeTensorQuant8AsymmPerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeTensorQuant8AsymmPerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::TENSOR_QUANT8_SYMM, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_QUANT8_SYMM, { .execTime = ParseSystemProperty(g_OperandTypeTensorQuant8SymmPerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeTensorQuant8SymmPerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::TENSOR_QUANT16_SYMM, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_QUANT16_SYMM, { .execTime = ParseSystemProperty(g_OperandTypeTensorQuant16SymmPerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeTensorQuant16SymmPerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL, { .execTime = ParseSystemProperty(g_OperandTypeTensorQuant8SymmPerChannelPerformanceExecTime, defaultValue), @@ -293,19 +298,19 @@ Return ArmnnDriverImpl::getCapabilities_1_2(const armnn::IRuntimePtr& runt ParseSystemProperty(g_OperandTypeTensorQuant8SymmPerChannelPerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::TENSOR_INT32, + update(&capabilities.operandPerformance, V1_2::OperandType::TENSOR_INT32, { .execTime = ParseSystemProperty(g_OperandTypeTensorInt32PerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeTensorInt32PerformancePowerUsage, defaultValue) }); - update(&capabilities.operandPerformance, OperandType::INT32, + update(&capabilities.operandPerformance, V1_2::OperandType::INT32, { .execTime = ParseSystemProperty(g_OperandTypeInt32PerformanceExecTime, defaultValue), .powerUsage = ParseSystemProperty(g_OperandTypeInt32PerformancePowerUsage, defaultValue) }); - cb(ErrorStatus::NONE, capabilities); + cb(V1_0::ErrorStatus::NONE, capabilities); } else { @@ -313,13 +318,17 @@ Return ArmnnDriverImpl::getCapabilities_1_2(const armnn::IRuntimePtr& runt capabilities.relaxedFloat32toFloat16PerformanceTensor.execTime = 0; // Set the base value for all operand types + #ifdef ARMNN_ANDROID_R + capabilities.operandPerformance = nonExtensionOperandPerformance({0.f, 0.0f}); + #else capabilities.operandPerformance = nonExtensionOperandPerformance({0.f, 0.0f}); + #endif - cb(ErrorStatus::DEVICE_UNAVAILABLE, capabilities); + cb(V1_0::ErrorStatus::DEVICE_UNAVAILABLE, capabilities); } return Void(); } } // namespace hal_1_2 -} // namespace armnn_driver +} // namespace armnn_driver \ No newline at end of file -- cgit v1.2.1