Skip to content

Commit

Permalink
fix (TF module.py): fixed an issue with the stateful Model class whic…
Browse files Browse the repository at this point in the history
…h expects all non-arraylikes to be passed as keywords. Modified the _call method to convert all arguments to keywords before calling super(Model, self).__call__
  • Loading branch information
YushaArif99 committed Aug 20, 2024
1 parent d720976 commit 4da886f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ivy/functional/backends/tensorflow/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,18 @@ def _call(self, *args, v=None, buffers=None, **kwargs):
elif hasattr(self.__call__, "wrapped"):
return self.__call__(*args, **kwargs)

return super(Model, self).__call__(*args, **kwargs) # noqa: UP008
# Get the signature of the call method
call_signature = inspect.signature(self.call)

# Convert all positional arguments to keyword arguments based on the signature
new_kwargs = {}
for idx, (param_name, param) in enumerate(call_signature.parameters.items()):
if idx < len(args):
new_kwargs[param_name] = args[idx]

# Merge the existing kwargs
new_kwargs.update(kwargs)
return super(Model, self).__call__(**new_kwargs) # noqa: UP008

@tf.autograph.experimental.do_not_convert
def build(
Expand Down

0 comments on commit 4da886f

Please sign in to comment.