blob: 9a47654477c4cceb0a1ff002899da8e9cc29d463 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#include "DynamicBackendUtils.hpp"
namespace armnn
{
void* DynamicBackendUtils::OpenHandle(const std::string& sharedObjectPath)
{
if (sharedObjectPath.empty())
{
throw RuntimeException("OpenHandle error: shared object path must not be empty");
}
void* sharedObjectHandle = dlopen(sharedObjectPath.c_str(), RTLD_LAZY | RTLD_GLOBAL);
if (!sharedObjectHandle)
{
throw RuntimeException(boost::str(boost::format("OpenHandle error: %1%") % GetDlError()));
}
return sharedObjectHandle;
}
void DynamicBackendUtils::CloseHandle(const void* sharedObjectHandle)
{
if (!sharedObjectHandle)
{
return;
}
dlclose(const_cast<void*>(sharedObjectHandle));
}
std::string DynamicBackendUtils::GetDlError()
{
const char* errorMessage = dlerror();
if (!errorMessage)
{
return "";
}
return std::string(errorMessage);
}
} // namespace armnn
|