[Tracker] Implement all `numpy.*` APIs in CuPy
See original GitHub issueImplement GPU version of numpy.*
functions in cupy.*
namespace.
This is a tracker issue that lists the remaining numpy.*
APIs (see also: comparison table). I’ve categorized them based on difficulty so that new contributors can pick the right task. Your contribution is highly welcomed and appreciated!
List of APIs
Very Easy
-
numpy.asfarray
(#6085) -
numpy.byte_bounds
(hint:ndarray.data.ptr
) (#7015) -
numpy.format_float_positional
(#6308) -
numpy.format_float_scientific
(#6474) -
numpy.ndarray.searchsorted
(#7059)
Easy
-
numpy.array_equiv
(#6254) -
numpy.asarray_chkfinite
(#6275) -
numpy.fabs
(#6282) -
numpy.float_power
(#6371) -
numpy.heaviside
(#6798) -
numpy.isneginf
(#6089) -
numpy.isposinf
(#6089) -
numpy.mask_indices
(#6156) -
numpy.ndarray.itemset
-
numpy.real_if_close
(#6475) -
numpy.setdiff1d
(#6433) -
numpy.setxor1d
(#6582) -
numpy.tril_indices
&numpy.tril_indices_from
(#6305) -
numpy.triu_indices
&numpy.triu_indices_from
(#6316) -
numpy.union1d
(#6357) -
numpy.lib.format.*
-
numpy.lib.stride_tricks.sliding_window_view
(#6956) -
numpy.emath.*
(numpy.lib.scimath.*
)
Low priority (iterator functions):
-
numpy.ndenumerate
-
numpy.nditer
-
numpy.nested_iters
Low priority (help functions):
-
numpy.info
-
numpy.lookfor
-
numpy.source
Low priority (internal functions):
-
numpy.deprecate
-
numpy.deprecate_with_doc
Medium
-
numpy.apply_over_axes
-
numpy.block
-
numpy.delete
-
numpy.geomspace
-
numpy.insert
(#6597) -
numpy.put_along_axis
-
numpy.row_stack
(#6312) -
numpy.spacing
-
numpy.vander
(#6279)
Low priority (dtype APIs - need to filter types unsupported by CuPy):
-
numpy.maximum_sctype
-
numpy.cast
(undocumented API) (hint: seenumpy/core/numerictypes.py
) -
numpy.typecodes
(undocumented API) -
numpy.sctypeDict
(undocumented API) -
numpy.sctypes
(undocumented API) -
numpy.nbytes
(undocumented API)
Low priority (rarely used APIs):
-
numpy.einsum_path
(#6723) -
numpy.frompyfunc
(maybe just call GUFunc?)
Medium to Hard
-
numpy.histogram_bin_edges
-
numpy.ediff1d
(#6280) -
numpy.intersect1d
(#6402, #6407) -
numpy.nanpercentile
-
numpy.nanquantile
-
numpy.ndarray.ctypes
(note: needs design discussion) -
numpy.ndarray.getfield
-
numpy.ndarray.resize
-
numpy.ndarray.setfield
-
numpy.polynomial.*
-
numpy.poly
(#3547, #6697) -
numpy.polyder
(#6469) -
numpy.polydiv
(#3780) -
numpy.polyint
-
numpy.trapz
(#6107)
Linear Algebra APIs:
-
numpy.linalg.cond
-
numpy.linalg.eig
-
numpy.linalg.eigvals
-
numpy.linalg.multi_dot
(#6358)
Random Sampling APIs:
-
numpy.random.Generator.*
(see the dedicated tracker issue for details: https://github.com/cupy/cupy/issues/4557)
Steps to Contribute
-
Fork and star ⭐ the CuPy repository 😉
-
Pick a function you want to work on. You can find the function in the NumPy API Reference to understand what should be implemented.
-
Implement a function in your branch. If you need help, join Gitter or just ask for help in this issue.
-
Don’t forget to write a test code!
-
Build CuPy and run tests to confirm that the function runs fine:
pip install -e . && pytest tests/cupy_tests/PATH_TO_YOUR_TEST
See the Contribution Guide for details. -
Submit a pull-request to the
master
branch.
Note that you will need a GPU environment to develop CuPy.
See also:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:13
- Comments:16 (14 by maintainers)
Top GitHub Comments
@rgommers Thank you for all the information. I’ve removed deprecated ones from the list:
numpy.loads
numpy.ndfromtxt
numpy.alen
numpy.asscalar
numpy.ndarray.tostring
numpy.set_numeric_ops
Also marked dtype-related functions as low priority as there’s an ongoing discussion in NumPy.
loads
andndfromtxt
were already removed in https://github.com/numpy/numpy/pull/19615, so can be removed from the list.With “typing stuff” do you mean the dtype-related functions (
cast
,typecodes
, etc.)? If so, then I agree - that’s questionable. Also xref https://github.com/numpy/numpy/issues/17325 for that.That sounds about right. The
random
andlinalg
stuff is important, as are some of the medium-hard functions likeput_along_axis
,nanquantile
,nanpercentile
, etc.All of the undocumented ones I’d like to get rid of in NumPy.