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

Paolo gcd branch #193

Merged
merged 3 commits into from
May 22, 2023
Merged

Paolo gcd branch #193

merged 3 commits into from
May 22, 2023

Conversation

PaoloGCD
Copy link
Contributor

Issue Number:

Objective of pull request:

Pull request checklist

Your PR fulfills the following requirements:

  • Issue created that explains the change and why it's needed
  • Tests are part of the PR (for bug fixes / features)
  • [] Docs reviewed and added / updated if needed (for bug fixes / features)
  • PR conforms to Coding Conventions
  • PR applys BSD 3-clause or LGPL2.1+ Licenses to all code files
  • Lint (flakeheaven lint src/lava tests/) and (bandit -r src/lava/.) pass locally
  • Build tests (pytest) passes locally

Pull request type

Please check your PR type:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation changes
  • Other (please describe):

What is the current behavior?

Describe the bug
Two bugs were found in the IO file:

fill_tensor() fails when a "graded" tensor is provided. This is because the payload requires slicing in the same way as the event components were done.

tensor_to_event() fails when a Torch tensor is provided. For some reason, np.argwhere() of a Torch tensor returns a row vector instead of the expected column vector. This can be solved by using torch.argwhere() when a tensor is provided and np.argwhere() when a NumPy array is provided."

What is the new behavior?

fill_tensor() works when graded tensor is provided
tensor_to_event() handles correctly torch tensors as input

Does this introduce a breaking change?

  • Yes
  • No

Supplemental information

paolocd added 2 commits May 10, 2023 12:36
np.argwhere of a torch tensor gives a row vector rather than a column vector as expected
Payload requires slicing with payload[valid_ind] as well
@PaoloGCD
Copy link
Contributor Author

Issue 192: #192

Copy link
Contributor

@bamsumit bamsumit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @PaoloGCD, looks good overall. I suggest adding a unittest to verify np array and torch tensor work identically.

Runs without exceptions, identical output as when using numpy array input, to_tensor(), and fill_tensor() are tested.
@bamsumit
Copy link
Contributor

@PaoloGCD Thanks for the PR. We appreciate the contribution. It looks good.

@bamsumit bamsumit merged commit 1c7e897 into lava-nc:main May 22, 2023
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

Successfully merging this pull request may close these issues.

2 participants