Skip to content

[doc] Add doc for importing SavedModel from TF Hub - #5523

Merged
antiagainst merged 8 commits into
iree-org:staging-docs-reworkfrom
antiagainst:tf-hub-import
Apr 21, 2021
Merged

antiagainst merged 8 commits into
iree-org:staging-docs-reworkfrom
antiagainst:tf-hub-import

Conversation

@antiagainst

@antiagainst antiagainst commented Apr 19, 2021 •

Copy link
Copy Markdown
Member

This covers the steps for using command-line tool, iree-tf-import.
It's the first step in the full IREE compilation flow.

Progress on #5453

This covers the steps for using command-line tool, `iree-tf-import`.
It's the first step in the full IREE compilation flow.

@ScottTodd ScottTodd 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.

Can you tag #5453 on this PR?

Comment thread mkdocs/docs/frontends/tensorflow.md Outdated
Comment on lines +52 to +56
First download the SavedModel and re-save it with a [serving signature](https://www.tensorflow.org/guide/saved_model#specifying_signatures_during_export).

!!! info
This is necessary because by default TensorFlow Hub SavedModels might not
have serving signatures, which are required for IREE compilation flow.

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.

Ideally this (re-saving using python code) would just be an optional step to note in a "troubleshooting" section, not a critical part of the import flow.

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.

To expand on this a bit further:

For cases that most users will hit, we should strive for the tools to do the heavy lifting. If that means editing iree-tf-import or writing a separate tool to re-save with serving signatures (in this case), we should prefer doing that over adding more steps to our documentation.

For cases that are rarer, or optional (such as for certain optimizations), we can defer to a "troubleshooting" or "tuning performance" section.

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.

(and it's great that you spotted this and figured out a way to make it work, doc writing and going through user flows is expected to uncover areas to improve like this, thanks!)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Agreed with your points. I've actually chatted with @silvasean and a mode to inspect possible entry points / exported names could be very useful and it could reduce the number of steps we require the user to take here. However, I'm not sure that we can go as far as to use iree-tf-import to modify the saved model. But @silvasean knows more there.

I agree with you that we should move the resaving into an optional step. I'm using MobileNet as an example here and I'd suspect it applies to other models from TF Hub, but indeed some SavedModel might already have that. So restructured a bit. Let me know what you think now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We could try a few more to see if there are shortcuts to take in practice, but unfortunately due to how SavedModel's work, the only really reliable way to know what you're getting is to load them in Python and save them in a controlled fashion.

SignatureDef saved models (i.e. "v1", though that's a misnomer as they are produced by both TF1 and TF2) are somewhat easier to handle. We can list the serving signatures, and if there is sufficiently good shape information in the model already then the user can just choose. For ObjectGraph saved models (i.e. "v2"), it gets complicated.

@antiagainst
antiagainst requested a review from ScottTodd April 21, 2021 15:12
Comment thread mkdocs/docs/frontends/tensorflow.md Resolved
Comment thread mkdocs/docs/frontends/tensorflow.md Resolved
Comment thread mkdocs/docs/frontends/tensorflow.md Resolved
Comment thread mkdocs/docs/frontends/tensorflow.md Resolved
@ScottTodd ScottTodd added documentation ✏️ Improvements or additions to documentation integrations/tensorflow TensorFlow model import and conversion labels Apr 21, 2021
@antiagainst
antiagainst requested a review from ScottTodd April 21, 2021 18:02
@antiagainst
antiagainst merged commit 205b667 into iree-org:staging-docs-rework Apr 21, 2021
@antiagainst
antiagainst deleted the tf-hub-import branch April 21, 2021 19:01
@antiagainst antiagainst linked an issue Apr 21, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation ✏️ Improvements or additions to documentation integrations/tensorflow TensorFlow model import and conversion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[New documentation] Write docs for "TensorFlow frontend"

3 participants