diff options
author | telsoa01 <telmo.soares@arm.com> | 2018-08-31 09:31:35 +0100 |
---|---|---|
committer | telsoa01 <telmo.soares@arm.com> | 2018-08-31 09:31:35 +0100 |
commit | ce3e84a8d449cbf31cee57e30f0eef6a96c0ce94 (patch) | |
tree | 77a769e27879fb712027c990071b061c5e0e3b60 /ArmnnDevice.cpp | |
parent | deb3bdbe028a59da0759dd7a560387d03a11d322 (diff) | |
download | android-nn-driver-ce3e84a8d449cbf31cee57e30f0eef6a96c0ce94.tar.gz |
Release 18.08
Diffstat (limited to 'ArmnnDevice.cpp')
-rw-r--r-- | ArmnnDevice.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/ArmnnDevice.cpp b/ArmnnDevice.cpp new file mode 100644 index 00000000..3e0b0da2 --- /dev/null +++ b/ArmnnDevice.cpp @@ -0,0 +1,65 @@ +// +// Copyright © 2017 Arm Ltd. All rights reserved. +// See LICENSE file in the project root for full license information. +// + +#include "ArmnnDevice.hpp" + +#include <OperationsUtils.h> + +#include <log/log.h> + +#include <memory> + +using namespace android; + +namespace armnn_driver +{ + +ArmnnDevice::ArmnnDevice(DriverOptions options) + : m_Runtime(nullptr, nullptr) + , m_ClTunedParameters(nullptr) + , m_Options(std::move(options)) +{ + ALOGV("ArmnnDevice::ArmnnDevice()"); + + armnn::ConfigureLogging(false, m_Options.IsVerboseLoggingEnabled(), armnn::LogSeverity::Trace); + if (m_Options.IsVerboseLoggingEnabled()) + { + SetMinimumLogSeverity(base::VERBOSE); + } + else + { + SetMinimumLogSeverity(base::INFO); + } + + try + { + armnn::IRuntime::CreationOptions options; + if (!m_Options.GetClTunedParametersFile().empty()) + { + m_ClTunedParameters = armnn::IGpuAccTunedParameters::Create(m_Options.GetClTunedParametersMode()); + try + { + m_ClTunedParameters->Load(m_Options.GetClTunedParametersFile().c_str()); + } + catch (const armnn::Exception& error) + { + // This is only a warning because the file won't exist the first time you are generating it. + ALOGW("ArmnnDevice: Failed to load CL tuned parameters file '%s': %s", + m_Options.GetClTunedParametersFile().c_str(), error.what()); + } + options.m_GpuAccTunedParameters = m_ClTunedParameters; + } + + options.m_EnableGpuProfiling = m_Options.IsGpuProfilingEnabled(); + + m_Runtime = armnn::IRuntime::Create(options); + } + catch (const armnn::ClRuntimeUnavailableException& error) + { + ALOGE("ArmnnDevice: Failed to setup CL runtime: %s. Device will be unavailable.", error.what()); + } +} + +} // namespace armnn_driver |