Skip to content

Commit 20ccde9

Browse files
Craigacpkarllessard
authored andcommitted
Adding a hook for loading TF IO native libraries (tensorflow#468)
1 parent 22714ca commit 20ccde9

File tree

1 file changed

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

1 file changed

+17
-1
lines changed

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

+17-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,21 @@ public static OpList loadLibrary(String filename) {
108109
}
109110
}
110111

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

0 commit comments

Comments
 (0)