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

Provide default mapping function for trivial pytorch functions from torch.nn #25

Open
bvogginger opened this issue Mar 21, 2024 · 1 comment
Assignees

Comments

@bvogginger
Copy link
Collaborator

Description

Currently, the conversion to/from nir of the following pytorch function is handled individually in each pytorch-based framework:

  • torch.nn.Conv2d
  • torch.nn.Linear

In the future this might apply to other functions like:

  • torch.nn.Conv1d and other convolution operations
  • torch.nn.AvgPool2d and other average pooling operations
  • torch.nn.MaxPool2d and other max pooling operations

This is related to this issue in snntorch: jeshraghian/snntorch#304

Suggestion

To reduce the amount of redundant code, we could implement default mapper functions for these pytorch native operations. This default mapper function could be applied to a nn.Module ore nir.node when the framework specific mapper function does not supply the operation.

Changes for conversion from pytorch to NIR

The suggestion is to implement a default mapper function like _extract_default_model
and call it if there is no NIRNode found by the framework dependent model_map function provided: https://github.com/neuromorphs/NIRTorch/blob/main/nirtorch/to_nir.py#L70

Changes for conversion from NIR to pytorch

Extend function _switch_default_models in https://github.com/neuromorphs/NIRTorch/blob/main/nirtorch/from_nir.py#L188

@bvogginger
Copy link
Collaborator Author

I'm working on this issue.

bvogginger added a commit to bvogginger/NIRTorch that referenced this issue Mar 27, 2024
This implements the NIR-to-torch conversion of issue neuromorphs#25
@bvogginger bvogginger self-assigned this Mar 28, 2024
bvogginger added a commit to bvogginger/NIRTorch that referenced this issue Mar 28, 2024
This implements the torch-to-NIR conversion of issue neuromorphs#25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant