-
Notifications
You must be signed in to change notification settings - Fork 11
Backends #39
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
Backends #39
Conversation
…ng to reshape2) for qudit systems.
…y math.floor() to int directly.
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.
Overall looks good, with some minor fixes required
|
||
size = self.sizen(a) | ||
if size == 0: | ||
return self.reshape(a, (0,)) |
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.
what is reshape (0) mean? just return a?
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.
Typically, a tensor with size=0 can still have multiple shape possibilities, such as shape=(2, 0, 5), (0, ), (0, 3). These three tensors with different shapes all belong to the size=0 case. To ensure consistent output under this API and avoid potential shape errors, we use reshape(a, (0, )).
LGTM now, thanks for the contribution |
@all-contributors please add @WeiguoMa for code, tests |
I've put up a pull request to add @WeiguoMa! 🎉 |
Add clip() and floor() functions for backends. Add reshaped() function to abstractbackend as a preparation for qudit systems. Add corresponding tests in tests/test_backends.py for clip() and floor().