telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | 93e4898 | 2018-09-05 13:05:09 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 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 | |
Matteo Martincigh | 01c9151 | 2019-01-31 15:40:08 +0000 | [diff] [blame^] | 38 | #if defined(ARMCOMPUTECL_ENABLED) |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 39 | try |
| 40 | { |
| 41 | armnn::IRuntime::CreationOptions options; |
| 42 | if (!m_Options.GetClTunedParametersFile().empty()) |
| 43 | { |
| 44 | m_ClTunedParameters = armnn::IGpuAccTunedParameters::Create(m_Options.GetClTunedParametersMode()); |
| 45 | try |
| 46 | { |
| 47 | m_ClTunedParameters->Load(m_Options.GetClTunedParametersFile().c_str()); |
| 48 | } |
| 49 | catch (const armnn::Exception& error) |
| 50 | { |
| 51 | // This is only a warning because the file won't exist the first time you are generating it. |
| 52 | ALOGW("ArmnnDevice: Failed to load CL tuned parameters file '%s': %s", |
| 53 | m_Options.GetClTunedParametersFile().c_str(), error.what()); |
| 54 | } |
| 55 | options.m_GpuAccTunedParameters = m_ClTunedParameters; |
| 56 | } |
| 57 | |
| 58 | options.m_EnableGpuProfiling = m_Options.IsGpuProfilingEnabled(); |
| 59 | |
| 60 | m_Runtime = armnn::IRuntime::Create(options); |
| 61 | } |
| 62 | catch (const armnn::ClRuntimeUnavailableException& error) |
| 63 | { |
| 64 | ALOGE("ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable.", error.what()); |
| 65 | } |
Matteo Martincigh | 01c9151 | 2019-01-31 15:40:08 +0000 | [diff] [blame^] | 66 | #endif |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | } // namespace armnn_driver |