telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // See LICENSE file in the project root for full license information. |
| 4 | // |
| 5 | |
Matteo Martincigh | e48bdff | 2018-09-03 13:50:50 +0100 | [diff] [blame] | 6 | #define LOG_TAG "ArmnnDriver" |
| 7 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 8 | #include "ArmnnDevice.hpp" |
| 9 | |
| 10 | #include <OperationsUtils.h> |
| 11 | |
| 12 | #include <log/log.h> |
| 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | using namespace android; |
| 17 | |
| 18 | namespace armnn_driver |
| 19 | { |
| 20 | |
| 21 | ArmnnDevice::ArmnnDevice(DriverOptions options) |
| 22 | : m_Runtime(nullptr, nullptr) |
| 23 | , m_ClTunedParameters(nullptr) |
| 24 | , m_Options(std::move(options)) |
| 25 | { |
| 26 | ALOGV("ArmnnDevice::ArmnnDevice()"); |
| 27 | |
| 28 | armnn::ConfigureLogging(false, m_Options.IsVerboseLoggingEnabled(), armnn::LogSeverity::Trace); |
| 29 | if (m_Options.IsVerboseLoggingEnabled()) |
| 30 | { |
| 31 | SetMinimumLogSeverity(base::VERBOSE); |
| 32 | } |
| 33 | else |
| 34 | { |
| 35 | SetMinimumLogSeverity(base::INFO); |
| 36 | } |
| 37 | |
| 38 | try |
| 39 | { |
| 40 | armnn::IRuntime::CreationOptions options; |
| 41 | if (!m_Options.GetClTunedParametersFile().empty()) |
| 42 | { |
| 43 | m_ClTunedParameters = armnn::IGpuAccTunedParameters::Create(m_Options.GetClTunedParametersMode()); |
| 44 | try |
| 45 | { |
| 46 | m_ClTunedParameters->Load(m_Options.GetClTunedParametersFile().c_str()); |
| 47 | } |
| 48 | catch (const armnn::Exception& error) |
| 49 | { |
| 50 | // This is only a warning because the file won't exist the first time you are generating it. |
| 51 | ALOGW("ArmnnDevice: Failed to load CL tuned parameters file '%s': %s", |
| 52 | m_Options.GetClTunedParametersFile().c_str(), error.what()); |
| 53 | } |
| 54 | options.m_GpuAccTunedParameters = m_ClTunedParameters; |
| 55 | } |
| 56 | |
| 57 | options.m_EnableGpuProfiling = m_Options.IsGpuProfilingEnabled(); |
| 58 | |
| 59 | m_Runtime = armnn::IRuntime::Create(options); |
| 60 | } |
| 61 | catch (const armnn::ClRuntimeUnavailableException& error) |
| 62 | { |
| 63 | ALOGE("ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable.", error.what()); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | } // namespace armnn_driver |