Skip to content

Commit

Permalink
Adding a hook for loading TF IO native libraries (tensorflow#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
Craigacp committed Sep 16, 2022
1 parent 2b9eca8 commit c11fd6b
Showing 1 changed file with 17 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,21 @@ public static OpList loadLibrary(String filename) {
}
}

/**
* Loads the filesystem plugin from filename 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 c11fd6b

Please sign in to comment.