Skip to content

Request: Support for cuPyNumeric #351

@TimothyEDawson

Description

@TimothyEDawson

cuPyNumeric aims to be a drop-in replacement for NumPy, with full API compatibility achieved by automatically falling back to NumPy for any functionality which isn't yet implemented.

I suspect this should make it a trivial addition to array-api-compat, although the way it falls back to NumPy may need to be explicitly handled as it returns NumPy ndarrays from any function marked with a dot in this table: https://docs.nvidia.com/cupynumeric/latest/api/comparison.html

For example:

>>> import cupynumeric as xp
>>> from array_api_compat import is_numpy_array
>>> 
>>> a = xp.linspace(0.0, 1.0, 21)
>>> is_numpy_array(a)
False
>>> b = xp.acos(a)
<cupynumeric internals>:241: RuntimeWarning: cuPyNumeric has not implemented numpy.acos and is falling back to canonical NumPy. You may notice significantly decreased performance for this function call.

Set CUPYNUMERIC_FALLBACK_STACKTRACE=1 and re-run to include a full stack trace with this warning.
>>> is_numpy_array(b)
True
>>>

I don't know if there's a preferred method to do so, but it's not difficult to programmatically check which functions do not yet have a native implementation. E.g.

>>> xp.acos.__module__
'numpy'
>>> xp.cos.__module__
'cupynumeric._ufunc.ufunc'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions