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

Resolve numpy 1.25 issues #973

Merged
merged 7 commits into from
Jun 23, 2023
Merged
Changes from 1 commit
Commits
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
22 changes: 2 additions & 20 deletions cunumeric/_ufunc/ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,33 +557,15 @@ def _find_common_type(
if len(unique_dtypes) == 1 and all_ndarray:
return arrs[0].dtype

# FIXME: The following is a miserable attempt to implement type
bryevdv marked this conversation as resolved.
Show resolved Hide resolved
# coercion rules that try to match NumPy's rules for a subset of cases;
# for the others, cuNumeric computes a type different from what
# NumPy produces for the same operands. Type coercion rules shouldn't
# be this difficult to imitate...

all_scalars = all(arr.ndim == 0 for arr in arrs)
all_arrays = all(arr.ndim > 0 for arr in arrs)
kinds = set(arr.dtype.kind for arr in arrs)
lossy_conversion = ("i" in kinds or "u" in kinds) and (
"f" in kinds or "c" in kinds
)
use_min_scalar = not (all_scalars or all_arrays or lossy_conversion)

scalar_types = []
array_types = []
for arr, orig_arg in zip(arrs, orig_args):
if arr.ndim == 0:
scalar_types.append(
np.dtype(np.min_scalar_type(orig_arg))
if use_min_scalar
else arr.dtype
)
scalar_types.append(orig_arg)
else:
array_types.append(arr.dtype)

return np.find_common_type(array_types, scalar_types) # type: ignore
return np.result_type(*array_types, *scalar_types)

def _resolve_dtype(
self,
Expand Down