Skip to content

Add support for dpctl.dparray. #50

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

Merged
merged 45 commits into from
Jan 13, 2021
Merged

Add support for dpctl.dparray. #50

merged 45 commits into from
Jan 13, 2021

Conversation

PokhodenkoSA
Copy link
Contributor

@PokhodenkoSA PokhodenkoSA commented Dec 4, 2020

Moved code from IntelPython/numba#116.

  • Update with main
  • Transform unit tests test_usmarray.py
  • Need to get rid of relative paths in setup.py

Copy link
Contributor

@DrTodd13 DrTodd13 left a comment

Choose a reason for hiding this comment

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

Looks correct at first glance. I didn't look to see why the tests were failing but that would be expected even if this is using the dpctl dparray branch since we removed the section of code there that looks for Numba meminfo objects. Once this is merged then I will add the code here to monkey-patch the meminfo objects with sycl_usm_array_interface.

DrTodd13 and others added 11 commits December 9, 2020 15:41
Co-authored-by: etotmeni <elena.totmenina@intel.com>
* Del dppl dir in tests

* Del unused var

Co-authored-by: etotmeni <elena.totmenina@intel.com>
Co-authored-by: etotmeni <elena.totmenina@intel.com>
Co-authored-by: Diptorup Deb <diptorup.deb@intel.com>
…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>
todo_getattr = []

# For all Numpy identifiers that have been registered for typing in Numba...
# this registry contains functions, getattrs, setattrs, casts and constants...need to do them all? FIX FIX FIX
Copy link
Contributor

Choose a reason for hiding this comment

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

Please convert this comment into a ticket.

@PokhodenkoSA
Copy link
Contributor Author

This code was moved to dpctl.dptensor.

Is it relate to some line?

@PokhodenkoSA
Copy link
Contributor Author

PokhodenkoSA commented Dec 11, 2020

This PR requires IntelPython/dpctl#214.

…ass and the Numba integration were in the same file. I changed those to explicitly refer to the usmarray module in dpctl.
…n numpy_usm_shared in dpctl.dptensor. This fixes the ndindex issue.
@PokhodenkoSA
Copy link
Contributor Author

PokhodenkoSA commented Dec 15, 2020

Assertion error in last case:

print("------------------- Testing Numba usmarray.T")
sys.stdout.flush()
dp4 = f12(dp3)
print("dp4:", dp4, type(dp4))
assert isinstance(dp4, usmarray.ndarray)
assert usmarray.has_array_interface(dp4)
del dp3
del dp4
------------------- Testing Numba usmarray.T
...
<class 'numpy.ndarray'>
Traceback (most recent call last):
  File "numba_dppy/tests/test_usmarray.py", line 220, in <module>
    assert isinstance(dp4, usmarray.ndarray)
AssertionError

Fixed.

etotmeni and others added 3 commits December 15, 2020 06:47
* Split tests for usmarray in separate unittest test cases

* Remove prints and use unittest assertions

* Move functions to tests

* Give names to functions

* Add expectedFailure for failed tests

* Clean code
@PokhodenkoSA
Copy link
Contributor Author

PokhodenkoSA commented Dec 15, 2020

3 tests failed and marked as expected failure:

  • test_numba_usmarray_mul_add - strange, it passed if runs not in batch
  • test_numba_usmarray_constructor_from_numpy_ndarray - was commented previously
  • test_numba_usmarray_T - did not work as I started

@DrTodd13
Copy link
Contributor

I would like to merge it. @DrTodd13 what is not ready yet?

I would like to merge it before #135 - black formatter. However I can do it in any order.

There are some parts of the USM array attribute class that use bound_function that don't seem to work with the current configuration and I'm not sure why. I say we merge what we currently have while I investigate this issue I described and we can have another PR for that.

@PokhodenkoSA
Copy link
Contributor Author

PokhodenkoSA commented Dec 23, 2020

@DrTodd13
I have find interesting tests dependency and possibly an issue. Have you any idea about it?

import numba
import numpy
import dpctl.dptensor.numpy_usm_shared as usmarray

@numba.njit()
def numba_mul(a, b):  # a is usmarray, b is numpy
    return a * b

@numba.njit()
def numba_mul_add(a):
    return a * 2.0 + 13

assert isinstance(numba_mul(usmarray.ones(10), numpy.ones(10)), usmarray.ndarray)  # 1
assert isinstance(numba_mul_add(numpy.ones(10)), numpy.ndarray)  # 2
assert isinstance(numba_mul_add(usmarray.ones(10)), usmarray.ndarray)  # 3 - error
Traceback (most recent call last):
  File "./usmarray_and_ndarray.py", line 27, in <module>
    assert isinstance(numba_mul_add(usmarray.ones(10)), usmarray.ndarray)
AssertionError

If any of 1 or 2 are commented then 3 passed.
If change order of 1 or 2 then 3 passed.

@PokhodenkoSA
Copy link
Contributor Author

@DrTodd13
I have made formatting for the code with black. If you will face merge conflicts do following:

pip install black
black .

@PokhodenkoSA PokhodenkoSA mentioned this pull request Jan 11, 2021
@PokhodenkoSA
Copy link
Contributor Author

PokhodenkoSA commented Jan 11, 2021

@DrTodd13 is it ready to be merged? How can I help with it?

@DrTodd13
Copy link
Contributor

@DrTodd13 is it ready to be merged? How can I help with it?

Yes. We can merge. There are some known issues to be fixed but let's get the stuff that is working checked in and fix the rest later.

@PokhodenkoSA
Copy link
Contributor Author

@diptorupd @DrTodd13
Could somebody of you please approve this PR ?

@PokhodenkoSA PokhodenkoSA merged commit bafd654 into main Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants