2 #include <torch/version.h>
9 #include <boost/dll/shared_library.hpp>
13 #include <unordered_map>
22 torch_table_functions_path /=
"QueryEngine";
23 torch_table_functions_path /=
"TableFunctions";
24 torch_table_functions_path /=
"SystemFunctions";
25 torch_table_functions_path /=
"os";
26 torch_table_functions_path /=
"Torch";
27 torch_table_functions_path /=
"TorchTableFunctions";
29 return torch_table_functions_path;
34 runtime_test_lib_tfs_path /=
"QueryEngine";
35 runtime_test_lib_tfs_path /=
"TableFunctions";
36 runtime_test_lib_tfs_path /=
"RuntimeLibTestFunctions";
37 runtime_test_lib_tfs_path /=
"RuntimeLibTestTableFunctions";
39 return runtime_test_lib_tfs_path;
44 runtime_test_lib_path /=
"QueryEngine";
45 runtime_test_lib_path /=
"TableFunctions";
46 runtime_test_lib_path /=
"RuntimeLibTestFunctions";
47 runtime_test_lib_path /=
"TestRuntimeLib";
49 return runtime_test_lib_path;
62 if (!torch_lib_path.empty()) {
63 boost::dll::fs::path lib_path(torch_lib_path);
64 libtorch = boost::dll::shared_library(
66 boost::dll::load_mode::rtld_global | boost::dll::load_mode::rtld_deepbind);
68 libtorch = boost::dll::shared_library(
"libtorch",
69 boost::dll::load_mode::search_system_folders |
70 boost::dll::load_mode::append_decorations |
71 boost::dll::load_mode::rtld_global |
72 boost::dll::load_mode::rtld_deepbind);
76 throw(std::runtime_error(
77 "Failed to load runtime library LibTorch. Support for library is disabled!"));
80 LOG(
WARNING) <<
"This HeavyDB was built against LibTorch version " << TORCH_VERSION
81 <<
". Using a different version of LibTorch may cause breaking behavior!";
94 boost::dll::load_mode::rtld_lazy | boost::dll::load_mode::search_system_folders |
95 boost::dll::load_mode::rtld_global | boost::dll::load_mode::append_decorations |
96 boost::dll::load_mode::rtld_deepbind);
99 std::runtime_error(
"Failed to load LibTorch table function module. LibTorch "
100 "table function support is disabled!"));
104 LOG(
FATAL) <<
"Load-time table function module does not contain "
105 "'init_table_functions' symbol!";
109 auto initFunction =
libTorchTFs.get<void(
void)>(
"init_table_functions");
120 boost::dll::load_mode::append_decorations |
121 boost::dll::load_mode::rtld_global |
122 boost::dll::load_mode::search_system_folders |
123 boost::dll::load_mode::rtld_deepbind);
126 throw(std::runtime_error(
"Failed to load test runtime library!"));
131 boost::dll::load_mode::rtld_lazy | boost::dll::load_mode::search_system_folders |
132 boost::dll::load_mode::rtld_global | boost::dll::load_mode::append_decorations |
133 boost::dll::load_mode::rtld_deepbind);
135 throw(std::runtime_error(
"Failed to load test runtime library table functions!!"));
138 if (!
testLibTFs.has(
"init_table_functions")) {
140 <<
"Test runtime table function library has no init_table_functions symbol!";
142 auto initFunction =
testLibTFs.get<void(
void)>(
"init_table_functions");
static void loadTestRuntimeLibs()
boost::filesystem::path get_runtime_test_lib_path()
std::string get_root_abs_path()
static void loadRuntimeLibs(const std::string &torch_lib_path=std::string())
boost::dll::shared_library testLib
static bool is_libtorch_loaded()
boost::dll::shared_library testLibTFs
boost::dll::shared_library libtorch
boost::filesystem::path get_runtime_test_lib_tfs_path()
static bool is_libtorch_loaded_
boost::filesystem::path get_torch_table_functions_path()
boost::dll::shared_library libTorchTFs