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

Replace native module implementation with managed code. #1398

Open
wants to merge 271 commits into
base: main
Choose a base branch
from

Conversation

NiklasGustafsson
Copy link
Contributor

This PR, which has been in the works for a while, replaces the implementation of many (but not all) built-in modules with an equivalent managed code implementation.

The rationale is primarily to follow what is done in Pytorch, where most modules are now implemented in Python. It also makes it easier to support access to a number of module 'attributes' in Pytorch, i.e. properties, which was harder to do with the native implementations, which did not support access to all such attributes.

This is a massive PR, but the patterns for replacements are just a few:

  1. Change the constructors to not call the native code module factories. Importantly, the constructors must not call RegisterComponents() like most custom modules should.

  2. Change the forward methods to invoke functional APIs instead of the native forward method.

  3. Implement each 'attribute' using a .NET property with a setter and a getter. The backing fields should be nullable, even if the property itself is not, because the constructor is expected to use the property setter for initialization.

@NiklasGustafsson
Copy link
Contributor Author

And thank you, @shaltielshmid for all the help on getting this one ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants