Skip to content

Fix unary reductions#369

Merged
magnatelee merged 16 commits intonv-legate:branch-22.05from
magnatelee:fix-unary-reduction
May 21, 2022
Merged

Fix unary reductions#369
magnatelee merged 16 commits intonv-legate:branch-22.05from
magnatelee:fix-unary-reduction

Conversation

@magnatelee
Copy link
Contributor

This PR to fix #359 and also make count_nonzero use the same template so that it can support axis.

@magnatelee magnatelee requested review from ipdemes and manopapad May 19, 2022 17:39
@magnatelee
Copy link
Contributor Author

cc @trxcllnt this PR might have some merge conflicts with your ongoing PR if you are working on the C++ code.

@ipdemes
Copy link
Contributor

ipdemes commented May 19, 2022

I know it wasn't in original tests, but could you, maybe, add tests for different array dimension from (up to LEGATE_MAX_DIM)?

@magnatelee
Copy link
Contributor Author

I know it wasn't in original tests, but could you, maybe, add tests for different array dimension from (up to LEGATE_MAX_DIM)?

dafa481

@magnatelee magnatelee requested review from ipdemes and manopapad May 19, 2022 20:25
@manopapad
Copy link
Contributor

This program:

import cunumeric as cn
print(cn.argmax(cn.ones((3,))))

is failing with:

Traceback (most recent call last):
  File "/Users/mpapadakis/legate.core/install/lib/python3.8/site-packages/legion_top.py", line 434, in legion_python_main
    run_path(args[start], run_name='__main__')
  File "/Users/mpapadakis/legate.core/install/lib/python3.8/site-packages/legion_top.py", line 255, in run_path
    exec(code, module.__dict__, module.__dict__)
  File "a.py", line 2, in <module>
    print(cn.argmax(cn.ones((3,))))
  File "/Users/mpapadakis/cunumeric/cunumeric/coverage.py", line 106, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/array.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/module.py", line 4447, in argmax
    return a.argmax(axis=axis, out=out)
  File "/Users/mpapadakis/cunumeric/cunumeric/coverage.py", line 106, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/array.py", line 1569, in argmax
    return self._perform_unary_reduction(
  File "/Users/mpapadakis/cunumeric/cunumeric/array.py", line 3558, in _perform_unary_reduction
    result._thunk.unary_reduction(
  File "/Users/mpapadakis/cunumeric/cunumeric/deferred.py", line 75, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/deferred.py", line 1703, in unary_reduction
    lhs_array.fill(np.array(fill_value, dtype=lhs_array.dtype))
OverflowError: Python int too large to convert to C long

and this:

import cunumeric as cn
print(cn.argmax(cn.array([1,2,3,1])))

is failing with:

Traceback (most recent call last):
  File "/Users/mpapadakis/legate.core/install/lib/python3.8/site-packages/legion_top.py", line 434, in legion_python_main
    run_path(args[start], run_name='__main__')
  File "/Users/mpapadakis/legate.core/install/lib/python3.8/site-packages/legion_top.py", line 255, in run_path
    exec(code, module.__dict__, module.__dict__)
  File "a.py", line 2, in <module>
    print(cn.argmax(cn.array([1,2,3,1])))
  File "/Users/mpapadakis/cunumeric/cunumeric/coverage.py", line 106, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/array.py", line 88, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/module.py", line 4447, in argmax
    return a.argmax(axis=axis, out=out)
  File "/Users/mpapadakis/cunumeric/cunumeric/coverage.py", line 106, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/array.py", line 1569, in argmax
    return self._perform_unary_reduction(
  File "/Users/mpapadakis/cunumeric/cunumeric/array.py", line 3558, in _perform_unary_reduction
    result._thunk.unary_reduction(
  File "/Users/mpapadakis/cunumeric/cunumeric/deferred.py", line 75, in wrapper
    return func(*args, **kwargs)
  File "/Users/mpapadakis/cunumeric/cunumeric/deferred.py", line 1703, in unary_reduction
    lhs_array.fill(np.array(fill_value, dtype=lhs_array.dtype))
  File "/Users/mpapadakis/cunumeric/cunumeric/deferred.py", line 1103, in fill
    assert numpy_array.size == 1
AssertionError

@magnatelee
Copy link
Contributor Author

@manopapad I think what you reported is a known issue: #87 argmin and argmax currently support only the cases where the output is at least 1-d and an axis is given. #346 is supposed to address it, so let's not fix it in this PR.

@magnatelee magnatelee requested a review from manopapad May 20, 2022 04:06
@magnatelee magnatelee merged commit 0879031 into nv-legate:branch-22.05 May 21, 2022
@magnatelee magnatelee deleted the fix-unary-reduction branch May 21, 2022 06:50
manopapad pushed a commit that referenced this pull request Nov 17, 2024
* update for LEGATE_ABORT change

* bump legate version
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.

Wrong behavior in unary reductions with specified axis

3 participants