Rename LoadLibrary to avoid conflict with Windows macros

PiperOrigin-RevId: 324939413
Change-Id: I2ad9f90c302f56ba4dfe847da44f9cd104457fbd
This commit is contained in:
A. Unique TensorFlower 2020-08-04 19:20:06 -07:00 committed by TensorFlower Gardener
parent eaa5235e00
commit 77ee5e0272
15 changed files with 27 additions and 27 deletions
tensorflow
third_party/eigen3/unsupported/Eigen/CXX11

View File

@ -213,7 +213,6 @@ void TF_Reset(const TF_SessionOptions* opt, const char** containers,
namespace tensorflow {
Status MessageToBuffer(const tensorflow::protobuf::MessageLite& in,
TF_Buffer* out) {
if (out->data != nullptr) {
@ -306,8 +305,8 @@ void TF_GraphSetOutputHandleShapesAndTypes(TF_Graph* graph, TF_Output output,
}
// Helpers for loading a TensorFlow plugin (a .so file).
Status LoadLibrary(const char* library_filename, void** result,
const void** buf, size_t* len);
Status LoadDynamicLibrary(const char* library_filename, void** result,
const void** buf, size_t* len);
// TODO(josh11b,mrry): Change Session to be able to use a Graph*
// directly, instead of requiring us to serialize to a GraphDef and
@ -552,7 +551,7 @@ void TF_PRun(TF_DeprecatedSession* s, const char* handle,
TF_Library* TF_LoadLibrary(const char* library_filename, TF_Status* status) {
TF_Library* lib_handle = new TF_Library;
status->status = tensorflow::LoadLibrary(
status->status = tensorflow::LoadDynamicLibrary(
library_filename, &lib_handle->lib_handle, &lib_handle->op_list.data,
&lib_handle->op_list.length);
if (!status->status.ok()) {

View File

@ -191,8 +191,8 @@ void* TF_LoadSharedLibrary(const char* library_filename, TF_Status* status) {
void* handle = nullptr;
TF_SetStatus(status, TF_OK, "");
::tensorflow::Set_TF_Status_from_Status(
status,
::tensorflow::Env::Default()->LoadLibrary(library_filename, &handle));
status, ::tensorflow::Env::Default()->LoadDynamicLibrary(library_filename,
&handle));
return handle;
}

View File

@ -462,7 +462,7 @@ Status RegisterFilesystemPlugin(const std::string& dso_path) {
// Step 1: Load plugin
Env* env = Env::Default();
void* dso_handle;
TF_RETURN_IF_ERROR(env->LoadLibrary(dso_path.c_str(), &dso_handle));
TF_RETURN_IF_ERROR(env->LoadDynamicLibrary(dso_path.c_str(), &dso_handle));
// Step 2: Load symbol for `TF_InitPlugin`
void* dso_symbol;

View File

@ -33,7 +33,6 @@ limitations under the License.
// Windows defines the following macros to convert foo to fooA or fooW,
// depending on the type of the string argument. We don't use these macros, so
// undefine them here.
#undef LoadLibrary
#undef CopyFile
#undef DeleteFile
#undef TranslateName

View File

@ -43,8 +43,8 @@ struct Library {
// and OpList. Ops and kernels are registered as globals when a library is
// loaded for the first time. Without caching, every subsequent load would not
// perform initialization again, so the OpList would be empty.
Status LoadLibrary(const char* library_filename, void** result,
const void** buf, size_t* len) {
Status LoadDynamicLibrary(const char* library_filename, void** result,
const void** buf, size_t* len) {
static mutex mu(LINKER_INITIALIZED);
static std::unordered_map<string, Library> loaded_libs;
Env* env = Env::Default();
@ -76,7 +76,7 @@ Status LoadLibrary(const char* library_filename, void** result,
return s;
}));
OpRegistry::Global()->DeferRegistrations();
s = env->LoadLibrary(library_filename, &library.handle);
s = env->LoadDynamicLibrary(library_filename, &library.handle);
if (s.ok()) {
s = OpRegistry::Global()->ProcessRegistrations();
}

View File

@ -1211,7 +1211,8 @@ void LoadDynamicKernelsInternal() {
if (s.ok() || override_abi_check) {
// TODO(gunan): Store the handles to the opened files.
void* unused_filehandle;
TF_CHECK_OK(env->LoadLibrary(fullpath.c_str(), &unused_filehandle));
TF_CHECK_OK(
env->LoadDynamicLibrary(fullpath.c_str(), &unused_filehandle));
} else {
LOG(WARNING) << "Not loading plugin library " << fullpath << ": "
<< s.error_message();

View File

@ -185,8 +185,9 @@ class PosixEnv : public Env {
});
}
Status LoadLibrary(const char* library_filename, void** handle) override {
return tensorflow::internal::LoadLibrary(library_filename, handle);
Status LoadDynamicLibrary(const char* library_filename,
void** handle) override {
return tensorflow::internal::LoadDynamicLibrary(library_filename, handle);
}
Status GetSymbolFromLibrary(void* handle, const char* symbol_name,

View File

@ -23,7 +23,7 @@ namespace tensorflow {
namespace internal {
Status LoadLibrary(const char* library_filename, void** handle) {
Status LoadDynamicLibrary(const char* library_filename, void** handle) {
*handle = dlopen(library_filename, RTLD_NOW | RTLD_LOCAL);
if (!*handle) {
return errors::NotFound(dlerror());

View File

@ -334,7 +334,8 @@ class Env {
// OK from the function.
// Otherwise returns nullptr in "*handle" and an error status from the
// function.
virtual Status LoadLibrary(const char* library_filename, void** handle) = 0;
virtual Status LoadDynamicLibrary(const char* library_filename,
void** handle) = 0;
// \brief Get a pointer to a symbol from a dynamic library.
//
@ -411,8 +412,9 @@ class EnvWrapper : public Env {
void SchedClosureAfter(int64 micros, std::function<void()> closure) override {
target_->SchedClosureAfter(micros, closure);
}
Status LoadLibrary(const char* library_filename, void** handle) override {
return target_->LoadLibrary(library_filename, handle);
Status LoadDynamicLibrary(const char* library_filename,
void** handle) override {
return target_->LoadDynamicLibrary(library_filename, handle);
}
Status GetSymbolFromLibrary(void* handle, const char* symbol_name,
void** symbol) override {

View File

@ -70,7 +70,7 @@ class LibHDFS {
private:
void LoadAndBind() {
auto TryLoadAndBind = [this](const char* name, void** handle) -> Status {
TF_RETURN_IF_ERROR(Env::Default()->LoadLibrary(name, handle));
TF_RETURN_IF_ERROR(Env::Default()->LoadDynamicLibrary(name, handle));
#define BIND_HDFS_FUNC(function) \
TF_RETURN_IF_ERROR(BindFunc(*handle, #function, &function));

View File

@ -22,7 +22,7 @@ namespace tensorflow {
namespace internal {
Status LoadLibrary(const char* library_filename, void** handle);
Status LoadDynamicLibrary(const char* library_filename, void** handle);
Status GetSymbolFromLibrary(void* handle, const char* symbol_name,
void** symbol);
string FormatLibraryFileName(const string& name, const string& version);

View File

@ -22,7 +22,6 @@ limitations under the License.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#undef LoadLibrary
#undef ERROR
#include <string>
@ -156,8 +155,9 @@ class WindowsEnv : public Env {
SetThreadpoolTimer(timer, &FileDueTime, 0, 0);
}
Status LoadLibrary(const char* library_filename, void** handle) override {
return tensorflow::internal::LoadLibrary(library_filename, handle);
Status LoadDynamicLibrary(const char* library_filename,
void** handle) override {
return tensorflow::internal::LoadDynamicLibrary(library_filename, handle);
}
Status GetSymbolFromLibrary(void* handle, const char* symbol_name,

View File

@ -22,7 +22,6 @@ limitations under the License.
#include <stdio.h>
#include <time.h>
#include <windows.h>
#undef LoadLibrary
#undef ERROR
#include "tensorflow/core/platform/errors.h"
@ -34,7 +33,7 @@ namespace tensorflow {
namespace internal {
Status LoadLibrary(const char* library_filename, void** handle) {
Status LoadDynamicLibrary(const char* library_filename, void** handle) {
string file_name = library_filename;
std::replace(file_name.begin(), file_name.end(), '/', '\\');

View File

@ -43,7 +43,7 @@ port::StatusOr<void*> GetDsoHandle(const string& name, const string& version) {
auto filename = port::Env::Default()->FormatLibraryFileName(name, version);
void* dso_handle;
port::Status status =
port::Env::Default()->LoadLibrary(filename.c_str(), &dso_handle);
port::Env::Default()->LoadDynamicLibrary(filename.c_str(), &dso_handle);
if (status.ok()) {
LOG(INFO) << "Successfully opened dynamic library " << filename;
return dso_handle;

View File

@ -11,5 +11,4 @@ inline void sleep(unsigned int seconds) { Sleep(1000*seconds); }
// prevent clashes.
#undef DeleteFile
#undef ERROR
#undef LoadLibrary
#endif // _WIN32