| 1121 | } |
| 1122 | |
| 1123 | void LoadDynamicKernelsInternal() { |
| 1124 | Env* env = Env::Default(); |
| 1125 | |
| 1126 | // Override to allow loading unsafe packages for development. |
| 1127 | // DO NOT USE UNLESS YOU KNOW WHAT ABI ISSUES YOU CAN ENCOUNTER. |
| 1128 | bool override_abi_check = |
| 1129 | strcmp(getenv("TF_REALLY_LOAD_UNSAFE_PACKAGES"), "1") == 0; |
| 1130 | |
| 1131 | string bazel_kernel_dir = |
| 1132 | io::JoinPath(env->GetRunfilesDir(), "tensorflow", "core", "kernels"); |
| 1133 | std::vector<string> files; |
| 1134 | Status s_kernel_dir = env->GetChildren(bazel_kernel_dir, &files); |
| 1135 | if (s_kernel_dir.ok()) { |
| 1136 | string dll_spec = io::JoinPath(bazel_kernel_dir, kKernelLibPattern); |
| 1137 | for (const auto& file : files) { |
| 1138 | string fullpath = io::JoinPath(bazel_kernel_dir, file); |
| 1139 | if (env->MatchPath(fullpath, dll_spec)) { |
| 1140 | Status s = IsProbablySafeToLoad(fullpath); |
| 1141 | if (!s.ok() && override_abi_check) { |
| 1142 | LOG(WARNING) << "Loading UNSAFE library " << fullpath |
| 1143 | << " because ABI check override is set: " |
| 1144 | << s.error_message(); |
| 1145 | } |
| 1146 | if (s.ok() || override_abi_check) { |
| 1147 | // TODO(gunan): Store the handles to the opened files. |
| 1148 | void* unused_filehandle; |
| 1149 | TF_CHECK_OK(env->LoadLibrary(fullpath.c_str(), &unused_filehandle)); |
| 1150 | } else { |
| 1151 | LOG(WARNING) << "Not loading plugin library " << fullpath << ": " |
| 1152 | << s.error_message(); |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | } |
| 1158 | |
| 1159 | // Mechanism for loading existing kernel libraries. |
| 1160 | void LoadDynamicKernels() { |
nothing calls this directly
no test coverage detected