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

Supporting "where" for unary operations #1061

Merged
merged 68 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f0eef07
adding support for adding where to unary reduction operations on the …
ipdemes Aug 29, 2023
a93748d
adding support for adding where to unary reduction operations on the …
ipdemes Aug 30, 2023
79c7aca
formatting
ipdemes Aug 30, 2023
a64e829
fixing error when calculation divisor
ipdemes Aug 30, 2023
6f7b059
fixing error with mean(where)
ipdemes Aug 31, 2023
d12fe55
updating test
ipdemes Sep 1, 2023
ec41b52
adding logic for where in unary_red on C++
ipdemes Sep 1, 2023
9128530
towards improving data usage by mean
ipdemes Sep 2, 2023
76dc871
debugging
ipdemes Sep 3, 2023
cbe93d9
removing debug output
ipdemes Sep 3, 2023
419a5af
adding support for broadcasting where + initial implementation of nan…
ipdemes Oct 11, 2023
0d7d66c
adding test for nanmean
ipdemes Oct 17, 2023
baf61ed
some clean-up + formatting
ipdemes Oct 17, 2023
30b1e18
fixing issues after rebase
ipdemes Oct 17, 2023
2277234
code clean-up
ipdemes Oct 17, 2023
73e0609
code clean-up
ipdemes Oct 18, 2023
dfafdcc
adding test_where for unary operations
ipdemes Oct 18, 2023
3071edd
adding nanmean to docs
ipdemes Oct 18, 2023
67aab76
nanmean is not oficiall method of ndarray
ipdemes Oct 18, 2023
09a4477
fixing test
ipdemes Oct 18, 2023
851dd42
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 9, 2023
83308a6
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 9, 2023
df70b28
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 9, 2023
7070d9f
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 9, 2023
c00661a
Update cunumeric/array.py
ipdemes Nov 9, 2023
ab3bb10
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 9, 2023
df5248e
Update src/cunumeric/unary/unary_red.cu
ipdemes Nov 9, 2023
8b3d0b7
Update cunumeric/array.py
ipdemes Nov 9, 2023
2a2ead5
Update cunumeric/array.py
ipdemes Nov 9, 2023
329bf5a
Update cunumeric/array.py
ipdemes Nov 9, 2023
dcce884
Update cunumeric/eager.py
ipdemes Nov 9, 2023
a50f165
Update cunumeric/module.py
ipdemes Nov 9, 2023
c52e0c5
Update cunumeric/array.py
ipdemes Nov 9, 2023
f7235b1
Update cunumeric/module.py
ipdemes Nov 9, 2023
568dfc5
updating documentation + fixing mypy issue
ipdemes Nov 9, 2023
67abe0c
cleaning up some of the C++ code
ipdemes Nov 9, 2023
bb8a462
Update cunumeric/array.py
ipdemes Nov 9, 2023
186af6f
fixing the logic for nanmean after previous commit
ipdemes Nov 13, 2023
2729b55
claning up scalar_unary_red_template.inl
ipdemes Nov 13, 2023
e675374
claning up unary_red_* files
ipdemes Nov 13, 2023
c17f3d2
removing convert_to_predicate_ndarray
ipdemes Nov 13, 2023
e7d9096
small clean-up
ipdemes Nov 13, 2023
b6a90c9
Update cunumeric/array.py
ipdemes Nov 13, 2023
7ec317c
removing where from perform_unary_op
ipdemes Nov 13, 2023
4709638
fixing logic for nanmin/nanmax for where
ipdemes Nov 13, 2023
95bfbeb
addressing the rest of the comments from Manolis
ipdemes Nov 14, 2023
90f27bc
some C++ code clean-up
ipdemes Nov 14, 2023
fa19be7
more C++ code clean-up
ipdemes Nov 14, 2023
a51135d
Update src/cunumeric/unary/unary_red.cu
ipdemes Nov 17, 2023
e703cc9
Update src/cunumeric/unary/unary_red.cc
ipdemes Nov 17, 2023
7ea110f
Update src/cunumeric/unary/unary_red_omp.cc
ipdemes Nov 17, 2023
f080a95
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 17, 2023
c039cb2
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 17, 2023
6896b4e
Update src/cunumeric/unary/unary_red_template.inl
ipdemes Nov 17, 2023
4014239
Update src/cunumeric/unary/scalar_unary_red_template.inl
ipdemes Nov 17, 2023
fe84bb1
Update src/cunumeric/unary/unary_red_template.inl
ipdemes Nov 17, 2023
70fa320
Update src/cunumeric/unary/unary_red.cu
ipdemes Nov 17, 2023
9d5b364
Update cunumeric/array.py
ipdemes Nov 17, 2023
2bd62eb
Update cunumeric/array.py
ipdemes Nov 17, 2023
f504f05
fixing bug in cuda code
ipdemes Nov 17, 2023
b15f656
adding dtype back to sum
ipdemes Nov 17, 2023
7a77535
removing ignore_nan
ipdemes Nov 17, 2023
b39364b
Merge remote-tracking branch 'origin/branch-24.01' into unary_red_where
ipdemes Nov 21, 2023
bdb49e9
fixing var for the case when where is not None
ipdemes Nov 30, 2023
4ef0749
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 30, 2023
18a6fe8
fixing eager logic for var
ipdemes Nov 30, 2023
7c1fdaa
Merge remote-tracking branch 'origin/branch-24.01' into unary_red_where
ipdemes Nov 30, 2023
869b176
removing dtype from _normalize_summation
ipdemes Dec 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cunumeric/_ufunc/ufunc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2021-2022 NVIDIA Corporation
# Copyright 2021-2023 NVIDIA Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,12 +14,17 @@
#
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Dict, Sequence, Union
from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Union

import numpy as np
from legate.core.utils import OrderedSet

from ..array import check_writeable, convert_to_cunumeric_ndarray, ndarray
from ..array import (
add_boilerplate,
check_writeable,
convert_to_cunumeric_ndarray,
ndarray,
)
from ..config import BinaryOpCode, UnaryOpCode, UnaryRedCode
from ..types import NdShape

Expand Down Expand Up @@ -680,6 +685,7 @@ def __call__(

return self._maybe_cast_output(out, result)

@add_boilerplate("array")
def reduce(
self,
array: ndarray,
Expand All @@ -688,7 +694,7 @@ def reduce(
out: Union[ndarray, None] = None,
keepdims: bool = False,
initial: Union[Any, None] = None,
where: bool = True,
where: Optional[ndarray] = None,
) -> ndarray:
"""
reduce(array, axis=0, dtype=None, out=None, keepdims=False, initial=<no
Expand Down Expand Up @@ -742,16 +748,10 @@ def reduce(
--------
numpy.ufunc.reduce
"""
array = convert_to_cunumeric_ndarray(array)

if self._red_code is None:
raise NotImplementedError(
manopapad marked this conversation as resolved.
Show resolved Hide resolved
f"reduction for {self} is not yet implemented"
)
if not isinstance(where, bool) or not where:
raise NotImplementedError(
"the 'where' keyword is not yet supported"
)

# NumPy seems to be using None as the default axis value for scalars
if array.ndim == 0 and axis == 0:
Expand Down
Loading