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

numba: Add support for the projection operator #336

Merged
merged 2 commits into from
Jun 19, 2020

Conversation

eric-wieser
Copy link
Member

Numba does not make it easy to overload __call__ at the moment.
We should follow up with numba to see if they can make it easier in future.

xref numba/numba#5885.

@eric-wieser eric-wieser added performance Maintenance Code cleanup without behavior changes labels Jun 19, 2020
Comment on lines -860 to -876
@numba.njit
def _project(mv, grade):
""" fast grade projection """
output = np.zeros_like(mv.value)
if grade == 0:
output[0] = mv.value[0]
elif grade == 1:
output[1:6] = mv.value[1:6]
elif grade == 2:
output[6:16] = mv.value[6:16]
elif grade == 3:
output[16:26] = mv.value[16:26]
elif grade == 4:
output[26:31] = mv.value[26:31]
elif grade == 5:
output[31] = mv.value[31]
return mv.layout.MultiVector(output)
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't actually seem to be any faster than my approach.

@lgtm-com
Copy link

lgtm-com bot commented Jun 19, 2020

This pull request introduces 3 alerts when merging c77a631 into bb0e2d1 - view on LGTM.com

new alerts:

  • 1 for Non-callable called
  • 1 for Unused local variable
  • 1 for Module is imported with 'import' and 'import from'

Copy link
Member

@hugohadfield hugohadfield left a comment

Choose a reason for hiding this comment

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

Looks good to me

Numba does not make it easy to overload `__call__` at the moment.
We should follow up with numba to see if they can make it easier in future.
@lgtm-com
Copy link

lgtm-com bot commented Jun 19, 2020

This pull request introduces 2 alerts when merging 581a135 into bb0e2d1 - view on LGTM.com

new alerts:

  • 1 for Non-callable called
  • 1 for Module is imported with 'import' and 'import from'

@eric-wieser eric-wieser merged commit a00a872 into pygae:master Jun 19, 2020
@eric-wieser
Copy link
Member Author

3.8 CI is the usual, LGTM complaints are github/codeql#3741 (invalid) and don't-care.

@eric-wieser eric-wieser deleted the project-jit branch September 16, 2020 09:31
@eric-wieser eric-wieser added this to the 1.4 release milestone Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Code cleanup without behavior changes performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants