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