Skip to content

Use lazy load to avoid loading libtensorflow_io.so until needed. - #1208

Merged
yongtang merged 2 commits into
tensorflow:masterfrom
yongtang:lazy-load
Dec 2, 2020
Merged

yongtang merged 2 commits into
tensorflow:masterfrom
yongtang:lazy-load

Conversation

@yongtang

@yongtang yongtang commented Nov 25, 2020 •

Copy link
Copy Markdown
Member

In tensorflow-io we have two shared libraries:

  • libtensorflow_io.so is linked with TF C++ API and does not have forward compatibility
  • libtensorflow_io_plugins.so is linked with TF C API and does have forward compatibility

The plan is to eventually have libtensorflow_io.so linked to TF C API only
but that will take a long time and requires rewriting C++ kernel (after modular kernel API is available in TF, unknown status now).

With both libtensorflow_io.so and libtensorflow_plugins.so loaded in import tensorflow_io as tfio,
the tensorflow-io package is not forward compatible even though our file systems implementations are forward compatible already.

In the meantime, one way to allow forward compatible for file systems, is to lazy load libtensorflow_io.so:

  • When user tries to run some function like decode_json they still encounter errors if they have newer versions of TF.
  • However, thwn user tries to just use the file system feature (e.g., azfs/http/etc), it works with newer versions of TF with tensorflow-io through import tensorflow_io as tfio (not touching any other submodules in tensorflow_io).

This PR is part of the #1111.

Signed-off-by: Yong Tang [email protected]

In tensorflow-io we have two shared libraries:
- `libtensorflow_io.so` is linked with TF C++ API and does not have forward compatibility
- `libtensorflow_io_plugins.so` is linked with TF C API and does have forward compatibility

The plan is to eventually have libtensorflow_io.so linked to TF C API only
but that will take a long time and requires rewriting C++ kernel (after modular kernel API is available in TF, unknown status now).

With both `libtensorflow_io.so` and `libtensorflow_plugins.so` loaded in `import tensorflow_io as tfio`,
the tensorflow-io package is not forward compatible even though our file systems implementations are forward compatible already.

In the meantime, one way to allow forward compatible for file systems, is to lazy load `libtensorflow_io.so`:
- When user tries to run some function like `decode_json` they still encounter errors if they have newer versions of TF.
- However, thwn user tries to just use the file system feature (e.g., azfs/http/etc), it works with newer versions of TF with tensorflow-io through `import tensorflow_io as tfio` (not touching any other submodules in `tensorflow_io`).

Signed-off-by: Yong Tang <[email protected]>
@yongtang
yongtang force-pushed the lazy-load branch 2 times, most recently from 9c1d342 to 9f55b80 Compare December 1, 2020 19:44
@yongtang
yongtang marked this pull request as ready for review December 2, 2020 00:54
@yongtang

yongtang commented Dec 2, 2020

Copy link
Copy Markdown
Member Author

/cc @terrytangyuan I exposed a tfio.exeprimental.oss which can be called through:

tfio.exeprimental.oss()

to invoke OSS support explicitly. This can help us go through transition until OSS is converted to C file system API.

@terrytangyuan terrytangyuan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Sounds good.

@yongtang
yongtang merged commit 85d018e into tensorflow:master Dec 2, 2020
i-ony pushed a commit to i-ony/io that referenced this pull request Feb 8, 2021
…sorflow#1208)

* Use lazy load to avoid loading libtensorflow_io.so until needed.

In tensorflow-io we have two shared libraries:
- `libtensorflow_io.so` is linked with TF C++ API and does not have forward compatibility
- `libtensorflow_io_plugins.so` is linked with TF C API and does have forward compatibility

The plan is to eventually have libtensorflow_io.so linked to TF C API only
but that will take a long time and requires rewriting C++ kernel (after modular kernel API is available in TF, unknown status now).

With both `libtensorflow_io.so` and `libtensorflow_plugins.so` loaded in `import tensorflow_io as tfio`,
the tensorflow-io package is not forward compatible even though our file systems implementations are forward compatible already.

In the meantime, one way to allow forward compatible for file systems, is to lazy load `libtensorflow_io.so`:
- When user tries to run some function like `decode_json` they still encounter errors if they have newer versions of TF.
- However, thwn user tries to just use the file system feature (e.g., azfs/http/etc), it works with newer versions of TF with tensorflow-io through `import tensorflow_io as tfio` (not touching any other submodules in `tensorflow_io`).

Signed-off-by: Yong Tang <[email protected]>

* Added tfio.experimental.oss() function to load OSS file system explicitly

Signed-off-by: Yong Tang <[email protected]>
@yongtang
yongtang deleted the lazy-load branch February 13, 2021 14:19
zheolong pushed a commit to zheolong/io-1 that referenced this pull request Jul 24, 2025
…sorflow#1208)

* Use lazy load to avoid loading libtensorflow_io.so until needed.

In tensorflow-io we have two shared libraries:
- `libtensorflow_io.so` is linked with TF C++ API and does not have forward compatibility
- `libtensorflow_io_plugins.so` is linked with TF C API and does have forward compatibility

The plan is to eventually have libtensorflow_io.so linked to TF C API only
but that will take a long time and requires rewriting C++ kernel (after modular kernel API is available in TF, unknown status now).

With both `libtensorflow_io.so` and `libtensorflow_plugins.so` loaded in `import tensorflow_io as tfio`,
the tensorflow-io package is not forward compatible even though our file systems implementations are forward compatible already.

In the meantime, one way to allow forward compatible for file systems, is to lazy load `libtensorflow_io.so`:
- When user tries to run some function like `decode_json` they still encounter errors if they have newer versions of TF.
- However, thwn user tries to just use the file system feature (e.g., azfs/http/etc), it works with newer versions of TF with tensorflow-io through `import tensorflow_io as tfio` (not touching any other submodules in `tensorflow_io`).

Signed-off-by: Yong Tang <[email protected]>

* Added tfio.experimental.oss() function to load OSS file system explicitly

Signed-off-by: Yong Tang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants