1 #include <c10/util/Exception.h> 2 #include <torch/csrc/jit/fuser/cpu/dynamic_library.h> 3 #include <torch/csrc/utils/disallow_copy.h> 13 static void* checkDL(
void* x) {
15 AT_ERROR(
"error in dlopen or dlsym: ", dlerror());
20 DynamicLibrary::DynamicLibrary(
const char* name) {
22 handle = checkDL(dlopen(name, RTLD_LOCAL | RTLD_NOW));
25 void* DynamicLibrary::sym(
const char* name) {
27 return checkDL(dlsym(handle, name));
30 DynamicLibrary::~DynamicLibrary() {
36 std::string DynamicLibrary::directoryOf(
void* addr) {
38 if (!dladdr(addr, &info)) {
39 AT_ERROR(
"could not look up address: ", addr);
41 std::string name = info.dli_fname;
42 std::vector<char> path(name.begin(), name.end());
43 char* directory = dirname(path.data());