Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a hook for loading TF IO native libraries #468

Merged
merged 4 commits into from
Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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