From 9bb7ebe53a9ed152b857c7295d80bf824112765c Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Thu, 4 Aug 2022 15:56:05 +0100 Subject: IVGCVSW-7062 'Gpu Tuning does not work with TfLite Benchmark tool' * Load the tuning file when GpuAcc is selected as a backend. Signed-off-by: Sadik Armagan Change-Id: I1d6b0237a87301f07681293a2c6dbc37e352dd28 --- shim/sl/canonical/ArmnnDevice.cpp | 50 ++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/shim/sl/canonical/ArmnnDevice.cpp b/shim/sl/canonical/ArmnnDevice.cpp index c40482246b..0017973b50 100644 --- a/shim/sl/canonical/ArmnnDevice.cpp +++ b/shim/sl/canonical/ArmnnDevice.cpp @@ -74,38 +74,40 @@ ArmnnDevice::ArmnnDevice(DriverOptions options) { SetMinimumLogSeverity(android::base::INFO); } - armnn::IRuntime::CreationOptions runtimeOptions; -#if defined(ARMCOMPUTECL_ENABLED) - try + if (std::find(m_Options.GetBackends().begin(), + m_Options.GetBackends().end(), + armnn::Compute::GpuAcc) != m_Options.GetBackends().end()) { - if (!m_Options.GetClTunedParametersFile().empty()) + try { - m_ClTunedParameters = armnn::IGpuAccTunedParameters::Create(m_Options.GetClTunedParametersMode(), - m_Options.GetClTuningLevel()); - try - { - m_ClTunedParameters->Load(m_Options.GetClTunedParametersFile().c_str()); - } - catch (std::exception& error) + if (!m_Options.GetClTunedParametersFile().empty()) { - // This is only a warning because the file won't exist the first time you are generating it. - VLOG(DRIVER) << "ArmnnDevice: Failed to load CL tuned parameters file " - << m_Options.GetClTunedParametersFile().c_str() << " : " << error.what()); + m_ClTunedParameters = armnn::IGpuAccTunedParameters::Create(m_Options.GetClTunedParametersMode(), + m_Options.GetClTuningLevel()); + try + { + m_ClTunedParameters->Load(m_Options.GetClTunedParametersFile().c_str()); + } + catch (std::exception& error) + { + // This is only a warning because the file won't exist the first time you are generating it. + VLOG(DRIVER) << "ArmnnDevice: Failed to load CL tuned parameters file " + << m_Options.GetClTunedParametersFile().c_str() << " : " << error.what(); + } + runtimeOptions.m_GpuAccTunedParameters = m_ClTunedParameters; } - runtimeOptions.m_GpuAccTunedParameters = m_ClTunedParameters; + } + catch (const armnn::ClRuntimeUnavailableException& error) + { + VLOG(DRIVER) << "ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable." << error.what(); + } + catch (std::exception& error) + { + VLOG(DRIVER) << "ArmnnDevice: Unknown exception: %s. Device will be unavailable." << error.what(); } } - catch (const armnn::ClRuntimeUnavailableException& error) - { - VLOG(DRIVER) << "ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable." << error.what(); - } - catch (std::exception& error) - { - VLOG(DRIVER) << "ArmnnDevice: Unknown exception: %s. Device will be unavailable." << error.what(); - } -#endif runtimeOptions.m_EnableGpuProfiling = m_Options.IsGpuProfilingEnabled(); m_Runtime = armnn::IRuntime::Create(runtimeOptions); -- cgit v1.2.1