Skip to content

Commit 6f81d8f

Browse files
committed
Adding a hook for loading TF IO native libraries.
1 parent 56883f0 commit 6f81d8f

File tree

1 file changed

+16
-1
lines changed
  • tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow

1 file changed

+16
-1
lines changed

tensorflow-core/tensorflow-core-api/src/main/java/org/tensorflow/TensorFlow.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2019-2021 The TensorFlow Authors. All Rights Reserved.
1+
/* Copyright 2019-2022 The TensorFlow Authors. All Rights Reserved.
22
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import static org.tensorflow.internal.c_api.global.tensorflow.TF_GetAllOpList;
2121
import static org.tensorflow.internal.c_api.global.tensorflow.TF_GetOpList;
2222
import static org.tensorflow.internal.c_api.global.tensorflow.TF_LoadLibrary;
23+
import static org.tensorflow.internal.c_api.global.tensorflow.TF_RegisterFilesystemPlugin;
2324
import static org.tensorflow.internal.c_api.global.tensorflow.TF_Version;
2425

2526
import com.google.protobuf.InvalidProtocolBufferException;
@@ -108,6 +109,20 @@ public static OpList loadLibrary(String filename) {
108109
}
109110
}
110111

112+
/**
113+
* Loads the filesystem plugin from fielname and registers all the filesystems it supports.
114+
* <p>
115+
* Throws a TF runtime exception if the plugin failed to load.
116+
* @param filename Path of the dynamic library containing the filesystem support.
117+
*/
118+
public static void registerFilesystemPlugin(String filename) {
119+
try (PointerScope scope = new PointerScope()) {
120+
TF_Status status = TF_Status.newStatus();
121+
TF_RegisterFilesystemPlugin(filename, status);
122+
status.throwExceptionIfNotOK();
123+
}
124+
}
125+
111126
private static TF_Library libraryLoad(String filename) {
112127
try (PointerScope scope = new PointerScope()) {
113128
TF_Status status = TF_Status.newStatus();

0 commit comments

Comments
 (0)