Skip to content

Commit

Permalink
Adding a hook for loading TF IO native libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
Craigacp committed Aug 19, 2022
1 parent 56883f0 commit 6f81d8f
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2019-2021 The TensorFlow Authors. All Rights Reserved.
/* Copyright 2019-2022 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
import static org.tensorflow.internal.c_api.global.tensorflow.TF_GetAllOpList;
import static org.tensorflow.internal.c_api.global.tensorflow.TF_GetOpList;
import static org.tensorflow.internal.c_api.global.tensorflow.TF_LoadLibrary;
import static org.tensorflow.internal.c_api.global.tensorflow.TF_RegisterFilesystemPlugin;
import static org.tensorflow.internal.c_api.global.tensorflow.TF_Version;

import com.google.protobuf.InvalidProtocolBufferException;
Expand Down Expand Up @@ -108,6 +109,20 @@ public static OpList loadLibrary(String filename) {
}
}

/**
* Loads the filesystem plugin from fielname and registers all the filesystems it supports.
* <p>
* Throws a TF runtime exception if the plugin failed to load.
* @param filename Path of the dynamic library containing the filesystem support.
*/
public static void registerFilesystemPlugin(String filename) {
try (PointerScope scope = new PointerScope()) {
TF_Status status = TF_Status.newStatus();
TF_RegisterFilesystemPlugin(filename, status);
status.throwExceptionIfNotOK();
}
}

private static TF_Library libraryLoad(String filename) {
try (PointerScope scope = new PointerScope()) {
TF_Status status = TF_Status.newStatus();
Expand Down

0 comments on commit 6f81d8f

Please sign in to comment.