Skip to content

Pass to rewrite Numpy function names to be able to overload them for Numba-dppy pipeline #52

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

Conversation

reazulhoque
Copy link
Contributor

The PR introduces a pass to rewrite the name of the Numpy function we intend to overload for Numba-dppy.

  1. We rewrite the name of selected functions to numba_dppy.dpnp.function_name.
  2. We create stub entried to make sure Numba finds the rewritten functions in numab_dppy.dpnp module.
  3. We provide implementation of the functions using the @overload decorator.

Currnetly it has examples of how we can use this method to overload np.sum and np.linalg.eig (incomplete). We will need to port existing functions we provide support for and also new ones.

Copy link
Contributor

@diptorupd diptorupd left a comment

Choose a reason for hiding this comment

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

@reazulhoque mostly high-level comments. Watch out for DPPL to DPPY renaming as that is coming in next release. We need documentation and comments.

dpnp_lowering.ensure_dpnp(name)

@classmethod
def dpctl_get_current_queue(cls):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we adding dpctl_* methods under the _DPNP_EXTENSION class? Any reason the class name is in all caps?


return dpnp_sum_impl

'''
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not a fan of having commented out code in the source. Please remove this code and bring it back once ready as a fresh PR.

return types.ExternalFunctionPointer(sig, get_pointer=get_pointer)

@classmethod
def dpnp_eig(cls, fn_name, type_names):
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the overload is not yet ready, we should remove this function from this PR and bring it back in a follow up.

class sum(Stub):
pass

class eig(Stub):
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

@@ -2,30 +2,49 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Was this file reformatted using black? We should avoid mixing reformatting with logical changes. Reformatting should be a separate PR. Otherwise it creates too much noise.

if isinstance(stmt, ir.Assign) and isinstance(stmt.value, ir.Expr):
lhs = stmt.target.name
rhs = stmt.value
# replace np.func(sum) with name from self.function_name_map
Copy link
Contributor

Choose a reason for hiding this comment

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

not just np.sum right?

@diptorupd diptorupd self-requested a review December 9, 2020 06:44
Copy link
Contributor

@diptorupd diptorupd left a comment

Choose a reason for hiding this comment

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

LGTM! merging this PR. Thanks!

@diptorupd diptorupd merged commit 0105e83 into IntelPython:main Dec 9, 2020
DrTodd13 pushed a commit that referenced this pull request Dec 10, 2020
…Numba-dppy pipeline (#52)

* Sum example

* Moved from infer_type, lower_builtin to overload

* Added two level module name functions

* Remove cython generated file

* Module name fix for moving to new extension

* Incomplete linalg.eig implementation

* Updted all dppl to dppy and moved rewrite_numpy_function_pass to it's own file

* Import module at correct locations

* Added comments

* Added test and updated comments

* Revert unneeded changes

* Update Eigen implementation

* Remove eig implementation

* Add checking equivalent IR

Co-authored-by: reazul.hoque <reazul.hoque@intel.com>
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.

5 participants