Skip to content

BUG: fix asanyarray fallback #940

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 5 commits into from
Oct 1, 2021

Conversation

samir-nasibli
Copy link

@samir-nasibli samir-nasibli commented Sep 16, 2021

Description

  • removed dpnp error raise, fallback when order is not c contiguous
    DPNP error: in function asanyarray() paramenter 'order' expected C, but 'None' provided -> 'int' object has no attribute 'c_contiguous'
  • disabled tests for ['int' object has no attribute 'c_contiguous']. See Reproduce dpctl usm_array flags below
tests/third_party/cupy/creation_tests/test_from_data.py::TestFromData::test_asanyarray_with_order
tests/third_party/cupy/creation_tests/test_from_data.py::TestFromData::test_asarray_from_numpy
tests/third_party/cupy/creation_tests/test_from_data.py::TestFromData::test_asarray_with_order

Test

FAILED tests/third_party/cupy/creation_tests/test_from_data.py::TestFromData::test_asanyarray_with_order

tests/third_party/cupy/creation_tests/test_from_data.py:365: in test_asanyarray_with_order
    b = xp.asanyarray(a, order=order)
dpnp/dpnp_iface_arraycreation.py:252: in asanyarray
    checker_throw_value_error("asanyarray", "order", order, 'C')
dpnp/dpnp_utils/dpnp_algo_utils.pyx:189: in dpnp.dpnp_utils.dpnp_algo_utils.checker_throw_value_error
    cpdef checker_throw_value_error(function_name, param_name, param, expected):
dpnp/dpnp_utils/dpnp_algo_utils.pyx:194: in dpnp.dpnp_utils.dpnp_algo_utils.checker_throw_value_error
    raise ValueError(err_msg)
E   AssertionError: Only cupy raises error
E   
E     File "/localdisk/work/snasibli/dpnp_work/tmp2/dpnp/tests/third_party/cupy/testing/helper.py", line 30, in _call_func
E       result = impl(self, *args, **kw)
E     File "/localdisk/work/snasibli/dpnp_work/tmp2/dpnp/tests/third_party/cupy/creation_tests/test_from_data.py", line 365, in test_asanyarray_with_order
E       b = xp.asanyarray(a, order=order)
E     File "/localdisk/work/snasibli/dpnp_work/tmp2/dpnp/dpnp/dpnp_iface_arraycreation.py", line 252, in asanyarray
E       checker_throw_value_error("asanyarray", "order", order, 'C')
E     File "dpnp/dpnp_utils/dpnp_algo_utils.pyx", line 189, in dpnp.dpnp_utils.dpnp_algo_utils.checker_throw_value_error
E       cpdef checker_throw_value_error(function_name, param_name, param, expected):
E     File "dpnp/dpnp_utils/dpnp_algo_utils.pyx", line 194, in dpnp.dpnp_utils.dpnp_algo_utils.checker_throw_value_error
E       raise ValueError(err_msg)
E   DPNP error: in function asanyarray() paramenter 'order' expected `C`, but 'None' provided

Now there are another fail on test:

tests/third_party/cupy/creation_tests/test_from_data.py:369: in test_asanyarray_with_order
    assert b.flags.c_contiguous
E   AssertionError: Only cupy raises error
E
E     File "/localdisk/work/snasibli/dpnp_work/tmp2/dpnp/tests/third_party/cupy/testing/helper.py", line 30, in _call_func
E       result = impl(self, *args, **kw)
E     File "/localdisk/work/snasibli/dpnp_work/tmp2/dpnp/tests/third_party/cupy/creation_tests/test_from_data.py", line 369, in test_asanyarray_with_order
E       assert b.flags.c_contiguous
E   'int' object has no attribute 'c_contiguous'

This fail happens due dpctl usm_ndarray, that have a bug for flags.

Reproduce dpctl usm_array flags

>>> a = dpnp.asanyarray([12,34], order='C')
>>> a = dpnp.asanyarray([12,34], order='K')
>>> a
<dpctl.tensor._usmarray.usm_ndarray object at 0x7fdec18e4130>
>>> a.flags
1
>>> import numpy
>>> b = numpy.asanyarray([12,34], order='K')
>>> b.flags
  C_CONTIGUOUS : True
  F_CONTIGUOUS : True
  OWNDATA : True
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False

'int' object has no attribute 'c_contiguous'

@samir-nasibli samir-nasibli added the in progress Please do not merge. Work is in progress. label Sep 16, 2021
@samir-nasibli samir-nasibli removed the in progress Please do not merge. Work is in progress. label Sep 16, 2021
@samir-nasibli
Copy link
Author

@Alexander-Makaryev I have disabled tests that fail due dpctl bug (see. Reproduce dpctl usm_array flags on description). If it is necessary I will create issue for this on dpctl repo.

@samir-nasibli samir-nasibli changed the title BUG: fix asanyarray fallback BUG: fix asanyarray fallback + disabled tests Sep 16, 2021
@Alexander-Makaryev
Copy link
Contributor

Alexander-Makaryev commented Sep 17, 2021

@oleksandr-pavlyk Could you please look at it? Is Samir right?

@oleksandr-pavlyk
Copy link
Contributor

usm_ndarray.flags indeed gives an integer, encoded using bits. Bit 0 is set if array is C-contiguous, bit 1 if F-contiguous and bit 2 if writeable.

@samir-nasibli
Copy link
Author

samir-nasibli commented Sep 21, 2021

@Alexander-Makaryev @oleksandr-pavlyk usm_ndarray interface is not compatible with these third-party/cupy test cases. numpy.ndarray for flags method returns numpy.flagsobj, while usm_ndarray returns int val for flags method. third-party/cupy test cases require flagsobj object. We shouldn't change third-party tests, we can only disable tests, what has already been done in this PR.

@Alexander-Makaryev
Copy link
Contributor

@samir-nasibli Could you please remove the skipping of tests from this PR?

@Alexander-Makaryev Alexander-Makaryev merged commit 8e7d554 into master Oct 1, 2021
@Alexander-Makaryev Alexander-Makaryev deleted the samir-nasibli/fix/asanyarray_fallback branch October 1, 2021 06:40
@samir-nasibli samir-nasibli changed the title BUG: fix asanyarray fallback + disabled tests BUG: fix asanyarray fallback Oct 1, 2021
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.

3 participants