Display exported concrete and polymorphic functions in SavedModel CLI#30752
Conversation
d7f62fc to
19e9319
Compare
vbardiovskyg
left a comment
There was a problem hiding this comment.
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 --allOutput |
vbardiovskyg
left a comment
There was a problem hiding this comment.
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 :) |
vbardiovskyg
left a comment
There was a problem hiding this comment.
Thanks for the change!
|
@vbardiovskyg , This should remove the linter issues. |
vbardiovskyg
left a comment
There was a problem hiding this comment.
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_clito 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