Merge pull request #43680 from yongtang:fs_api
PiperOrigin-RevId: 337929031 Change-Id: Ia9370b1ce576cf0446bd4eaed267b9d5eaa2cdcc
This commit is contained in:
commit
31547630e0
@ -348,6 +348,8 @@
|
|||||||
context.
|
context.
|
||||||
* Add `tf.config.experimental.mlir_bridge_rollout` which will help us
|
* Add `tf.config.experimental.mlir_bridge_rollout` which will help us
|
||||||
rollout the new MLIR TPU bridge.
|
rollout the new MLIR TPU bridge.
|
||||||
|
* Added `tf.experimental.register_filesystem_plugin` to load modular
|
||||||
|
filesystem plugins from Python
|
||||||
* <ADD RELEASE NOTES HERE>
|
* <ADD RELEASE NOTES HERE>
|
||||||
|
|
||||||
## Thanks to our Contributors
|
## Thanks to our Contributors
|
||||||
|
@ -202,6 +202,7 @@ tf_cuda_library(
|
|||||||
":tf_status",
|
":tf_status",
|
||||||
":tf_tensor",
|
":tf_tensor",
|
||||||
"@com_google_absl//absl/strings",
|
"@com_google_absl//absl/strings",
|
||||||
|
"//tensorflow/c/experimental/filesystem:modular_filesystem",
|
||||||
"//tensorflow/cc/saved_model:loader_lite",
|
"//tensorflow/cc/saved_model:loader_lite",
|
||||||
"//tensorflow/cc:gradients",
|
"//tensorflow/cc:gradients",
|
||||||
"//tensorflow/cc:ops",
|
"//tensorflow/cc:ops",
|
||||||
|
@ -25,6 +25,7 @@ limitations under the License.
|
|||||||
#include "tensorflow/core/platform/platform.h" // NOLINT
|
#include "tensorflow/core/platform/platform.h" // NOLINT
|
||||||
|
|
||||||
#if !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD)
|
#if !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD)
|
||||||
|
#include "tensorflow/c/experimental/filesystem/modular_filesystem.h"
|
||||||
#include "tensorflow/cc/framework/gradients.h"
|
#include "tensorflow/cc/framework/gradients.h"
|
||||||
#include "tensorflow/cc/framework/ops.h"
|
#include "tensorflow/cc/framework/ops.h"
|
||||||
#include "tensorflow/cc/framework/scope_internal.h"
|
#include "tensorflow/cc/framework/scope_internal.h"
|
||||||
@ -2606,4 +2607,14 @@ void TF_RegisterLogListener(void (*listener)(const char*)) {
|
|||||||
#endif // !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD)
|
#endif // !defined(IS_MOBILE_PLATFORM) && !defined(IS_SLIM_BUILD)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TF_RegisterFilesystemPlugin(const char* plugin_filename,
|
||||||
|
TF_Status* status) {
|
||||||
|
#if defined(IS_MOBILE_PLATFORM) || defined(IS_SLIM_BUILD)
|
||||||
|
status->status = tensorflow::errors::Unimplemented(
|
||||||
|
"FileSystem plugin functionality is not supported on mobile");
|
||||||
|
#else
|
||||||
|
status->status = tensorflow::RegisterFilesystemPlugin(plugin_filename);
|
||||||
|
#endif // defined(IS_MOBILE_PLATFORM) || defined(IS_SLIM_BUILD)
|
||||||
|
}
|
||||||
|
|
||||||
} // end extern "C"
|
} // end extern "C"
|
||||||
|
@ -1577,6 +1577,13 @@ TF_CAPI_EXPORT extern void TF_DeleteServer(TF_Server* server);
|
|||||||
TF_CAPI_EXPORT extern void TF_RegisterLogListener(
|
TF_CAPI_EXPORT extern void TF_RegisterLogListener(
|
||||||
void (*listener)(const char*));
|
void (*listener)(const char*));
|
||||||
|
|
||||||
|
// Register a FileSystem plugin from filename `plugin_filename`.
|
||||||
|
//
|
||||||
|
// On success, place OK in status.
|
||||||
|
// On failure, place an error status in status.
|
||||||
|
TF_CAPI_EXPORT extern void TF_RegisterFilesystemPlugin(
|
||||||
|
const char* plugin_filename, TF_Status* status);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* end extern "C" */
|
} /* end extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1155,6 +1155,13 @@ PYBIND11_MODULE(_pywrap_tf_session, m) {
|
|||||||
return "TensorHandle";
|
return "TensorHandle";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m.def("TF_RegisterFilesystemPlugin", [](const char* plugin_filename) {
|
||||||
|
tensorflow::Safe_TF_StatusPtr status =
|
||||||
|
tensorflow::make_safe(TF_NewStatus());
|
||||||
|
TF_RegisterFilesystemPlugin(plugin_filename, status.get());
|
||||||
|
tensorflow::MaybeRaiseRegisteredFromTFStatus(status.get());
|
||||||
|
});
|
||||||
|
|
||||||
py::enum_<TF_DataType>(m, "TF_DataType")
|
py::enum_<TF_DataType>(m, "TF_DataType")
|
||||||
.value("TF_FLOAT", TF_FLOAT)
|
.value("TF_FLOAT", TF_FLOAT)
|
||||||
.value("TF_DOUBLE", TF_DOUBLE)
|
.value("TF_DOUBLE", TF_DOUBLE)
|
||||||
|
@ -157,3 +157,27 @@ def load_library(library_location):
|
|||||||
errno.ENOENT,
|
errno.ENOENT,
|
||||||
'The file or folder to load kernel libraries from does not exist.',
|
'The file or folder to load kernel libraries from does not exist.',
|
||||||
library_location)
|
library_location)
|
||||||
|
|
||||||
|
|
||||||
|
@tf_export('experimental.register_filesystem_plugin')
|
||||||
|
def register_filesystem_plugin(plugin_location):
|
||||||
|
"""Loads a TensorFlow FileSystem plugin.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
plugin_location: Path to the plugin. Relative or absolute filesystem plugin
|
||||||
|
path to a dynamic library file.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
None
|
||||||
|
|
||||||
|
Raises:
|
||||||
|
OSError: When the file to be loaded is not found.
|
||||||
|
RuntimeError: when unable to load the library.
|
||||||
|
"""
|
||||||
|
if os.path.exists(plugin_location):
|
||||||
|
py_tf.TF_RegisterFilesystemPlugin(plugin_location)
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise OSError(errno.ENOENT,
|
||||||
|
'The file to load file system plugin from does not exist.',
|
||||||
|
plugin_location)
|
||||||
|
@ -20,4 +20,8 @@ tf_module {
|
|||||||
name: "output_all_intermediates"
|
name: "output_all_intermediates"
|
||||||
argspec: "args=[\'state\'], varargs=None, keywords=None, defaults=None"
|
argspec: "args=[\'state\'], varargs=None, keywords=None, defaults=None"
|
||||||
}
|
}
|
||||||
|
member_method {
|
||||||
|
name: "register_filesystem_plugin"
|
||||||
|
argspec: "args=[\'plugin_location\'], varargs=None, keywords=None, defaults=None"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,4 +28,8 @@ tf_module {
|
|||||||
name: "function_executor_type"
|
name: "function_executor_type"
|
||||||
argspec: "args=[\'executor_type\'], varargs=None, keywords=None, defaults=None"
|
argspec: "args=[\'executor_type\'], varargs=None, keywords=None, defaults=None"
|
||||||
}
|
}
|
||||||
|
member_method {
|
||||||
|
name: "register_filesystem_plugin"
|
||||||
|
argspec: "args=[\'plugin_location\'], varargs=None, keywords=None, defaults=None"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user