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

pass bundle object to make_tf_function #5708

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions torch_xla/tf_saved_model_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def inner(*args):
return inner


def make_tf_function(stablehlo_program: stablehlo.StableHLOGraphModule):
return _wrap_as_tf_func(stablehlo_program._bundle.stablehlo_funcs[0],
stablehlo_program._bundle)
def make_tf_function(stablehlo_program: stablehlo.StableHLOGraphModule,
bundle=None):
if bundle is None:
return _wrap_as_tf_func(stablehlo_program._bundle.stablehlo_funcs[0],
stablehlo_program._bundle)
return _wrap_as_tf_func(stablehlo_program._bundle.stablehlo_funcs[0], bundle)


def _make_input_signatures(
Expand Down Expand Up @@ -86,7 +89,8 @@ def save_stablehlo_graph_as_tf(
input_signatures = list(
_make_input_signatures(bundle.stablehlo_funcs[0].meta))
tfm.f = tf.function(
make_tf_function(stablehlo_program), input_signature=input_signatures)
make_tf_function(stablehlo_program, bundle),
input_signature=input_signatures)
tfm._variables = (
list(bundle.state_dict.values()) + bundle.additional_constants)
signatures = {serving_key: tfm.f.get_concrete_function(*input_signatures)}
Expand Down