-
Notifications
You must be signed in to change notification settings - Fork 74.2k
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
Display exported concrete and polymorphic functions in SavedModel CLI #30752
Display exported concrete and polymorphic functions in SavedModel CLI #30752
Conversation
d7f62fc
to
19e9319
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing. I think this is a great first step to start showing defined functions on SavedModelV2s that don't expose any v1 style signatures.
Could you please copy/paste a typical output of the CLI feature you are adding into the review comment?
As Requested, Output of SavedModel2.0 Modelimport tensorflow.compat.v2 as tf
tf.enable_v2_behaviour()
class A(tf.train.Checkpoint):
@tf.function
def func1(self, a, b, c):
if c:
return a + b
else:
return a * b
@tf.function(input_signature=[tf.TensorSpec(shape=(2, 2), dtype=tf.float32)])
def func2(self, x):
return x + 2
@tf.function
def __call__(self, y, c=7):
return y + 2 * c
a = A()
a.func1(tf.constant(5), tf.constant(9), {"key1": [{"k1":tf.constant(5), "k2":1}, 2], "key2": 2})
a.func1(tf.constant(5), tf.constant(9), False)
a(tf.constant(5))
tf.saved_model.save(a, "/tmp/model") Run$ saved_model_cli show --dir /tmp/model --all Output
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay.
The PR looks good except for the single comment and also the missing test. Please add at least one to saved_model_cli_test. Most of that file is loading a model from saved_model/testdata/half_plus_two/00000123
, but I think you can just create a model and save it in temp directory, then load it, all from one test function.
…ete function ID. Skipped TF 1.X models while showing Polymorphic function.
Added the test, @vbardiovskyg please take a look :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@vbardiovskyg , This should remove the linter issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why you didn't break the line using "" or brackets, but approving since it is not a big deal.
PiperOrigin-RevId: 263717252
Adding features to
saved_model_cli
to show SavedModel2.0 Functions.SavedModelCLI doesn't show details of Polymorphic Functions or multiple Concrete Functions. This Pull request addresses this problem,
The Sample output is provided here: #30752 (comment)
This PR is made for Google Summer of Code 2019
CC: @vbardiovskyg @srjoglekar246