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

[RFC] Deprecate the iree-import-tf tool and iree-tools-tf package #19917

Open
8 tasks
ScottTodd opened this issue Feb 5, 2025 · 1 comment
Open
8 tasks

[RFC] Deprecate the iree-import-tf tool and iree-tools-tf package #19917

ScottTodd opened this issue Feb 5, 2025 · 1 comment
Labels
discussion Proposals, open-ended questions, etc integrations/tensorflow TensorFlow model import and conversion

Comments

@ScottTodd
Copy link
Member

ScottTodd commented Feb 5, 2025

I propose we move to delete the existing TensorFlow support code and packages and direct users to upstream tools (if they exist) to produce programs in one of IREE's supported input formats (StableHLO/TOSA/Torch/Linalg MLIR).

Motivation

Issues like #19852 have recently shown that our support for importing from TensorFlow SavedModel and compiling via StableHLO is no longer reliable. I also have not seen many users deliberately using TensorFlow lately (TensorFlow Lite is a slightly different story), though several of our documentation pages still use TensorFlow as a guiding example. Separate from this RFC, I plan on updating those pages to use a different framework like ONNX.

Background

Our current import pipeline relies on the iree-import-tf tool that we publish as part of the iree-tools-tf package:

The import tool uses the experimental_run_pass_pipeline API from TensorFlow's Python packages, running the tf-lower-to-mlprogram-and-hlo pipeline. This produces StableHLO but not VHLO, so it is not subject to the compatibility guarantees that StableHLO advertises: https://openxla.org/stablehlo/compatibility.

Upstream alternatives

We can work with StableHLO (https://github.com/openxla/stablehlo) and TensorFlow (https://github.com/tensorflow/tensorflow/) maintainers to see what path (if any) from TensorFlow to our compiler can be supported. There are existing guides like https://openxla.org/stablehlo/tutorials/jax-export that show existing paths. This might need a new path, or maybe TF -> TFLite -> TOSA.

I'd like us to get to a state where we can say "follow this upstream guide to get into this format, then we'll support it". Right now, we provide our own packages built on experimental and unsupported APIs and this is too much of a support burden.

Deprecation tasklist

@ScottTodd ScottTodd added discussion Proposals, open-ended questions, etc integrations/tensorflow TensorFlow model import and conversion labels Feb 5, 2025
@ScottTodd
Copy link
Member Author

Following some discussion at openxla/stablehlo#2708, it seems that there are now stable APIs that can convert from TF SavedModel to StableHLO portable artifacts (VHLO MLIR bytecode). I have a little demo notebook here: https://colab.research.google.com/gist/ScottTodd/d7c5328a0a383cd8cc0dc2a2da827f7f/tf-to-vhlo-to-iree.ipynb. The main APIs are

from tensorflow.compiler.mlir.stablehlo import stablehlo
from tensorflow.compiler.mlir.tensorflow_to_stablehlo.python import pywrap_tensorflow_to_stablehlo as tensorflow_to_stablehlo

module_bytecode = tensorflow_to_stablehlo.savedmodel_to_stablehlo(input_path=...,)
target = stablehlo.get_current_version()
portable_byte_str = stablehlo.serialize_portable_artifact_str(module_bytecode, target)

We could change https://github.com/iree-org/iree/blob/main/integrations/tensorflow/python_projects/iree_tf/iree/tools/tf/scripts/iree_import_tf/__main__.py to run that code instead of the experimental APIs, mainly if we want a CLI tool that users can import with. I think at that point, we could include the iree-import-tf console script alongside iree-import-onnx in the iree-base-compiler package, as a [tf] extra, then still deprecate and delete the iree-tools-tf package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Proposals, open-ended questions, etc integrations/tensorflow TensorFlow model import and conversion
Projects
None yet
Development

No branches or pull requests

1 participant