-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
feat(stateful): Add NativeModule
to all backends with the implementation of a custom tensorflow.keras.Model
subclass for the tensorflow
backend to follow ivy.Module
's API
#27955
Conversation
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.
PR Compliance Checks
Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.
Issue Reference
In order to be considered for merging, the pull request description must refer to a specific issue number. This is described in our contributing guide and our PR template.
This check is looking for a phrase similar to: "Fixes #XYZ" or "Resolves #XYZ" where XYZ is the issue number that this PR is meant to address.
Protected Branch
In order to be considered for merging, the pull request changes must not be implemented on the "main" branch. This is described in our Contributing Guide. We are closing this pull request and we would suggest that you implement your changes as described in our Contributing Guide and open a new pull request.
Hey @vedpatwardhan, could you take a look? I didn't remove some more attributes, properties, arguments which I think can be safely removed for our use case but for the time being this version of the class works. We can then revisit and remove any unneeded code from the file |
ivy/stateful/__init__.py
Outdated
@@ -1,3 +1,4 @@ | |||
from . import backends |
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.
The only concern here is that we'd import tensorflow
on importing ivy
, thus adding it as a dependency. Let's probably do something like create a submodule named module.py
in all the backends and add the keras model implementation in the tensorflow
backend. After that we can just add a NativeModule
to all the backend __init__.py
files so that based on the backend, that particular model would be contained in ivy.NativeModule
. After that we can just do the same thing as we're doing now except for the namespace change
Apologies for the delayed review @hmahmood24, let me know what you think, thanks 😄
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.
Ah didn't think of it from that perspective. Thanks for the suggestion! 👍🏼
…a custom Model class for the tensorflow backend NativeModule
@vedpatwardhan For the time being, I've kept the |
tensorflow.keras.Model
stateful class to follow ivy.Module
's APINativeModule
to all backends with the implementation of a custom NativeModule class for the tensorflow
backend to follow ivy.Module
's API
NativeModule
to all backends with the implementation of a custom NativeModule class for the tensorflow
backend to follow ivy.Module
's APINativeModule
to all backends with the implementation of a custom tensorflow.keras.Model
subclass for the tensorflow
backend to follow ivy.Module
's API
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.
@vedpatwardhan For the time being, I've kept the
module.py
sub-module in all the backends empty except fortensorflow
. For all the other backends, theNativeModule
points to the backend native modules e.g. fortorch
points totorch.nn.Module
, forpaddle
points topaddle.nn.Layer
and so on. Let me know if this makes sense? Thanks!
Yep sounds good, tbh even if we had set NativeModule
as None
for those backends it wouldn't be a problem but setting it as the native module of the framework by default sounds good! Feel free to merge the PR, thanks @hmahmood24 😄
PR Description
Adds
tensorflow.keras.Model
stateful class that inherits directly fromtf.keras.Model
and also implements the front-facing API followingivy.Module
. Also adds an additionalcall
method to the frontendnn.Module
class.Related Issue
Closes #
Checklist
Socials