question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Tracker] Implement all `numpy.*` APIs in CuPy

See original GitHub issue

Implement 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: see numpy/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:

Steps to Contribute

  1. Fork and star ⭐ the CuPy repository 😉

  2. Pick a function you want to work on. You can find the function in the NumPy API Reference to understand what should be implemented.

  3. Implement a function in your branch. If you need help, join Gitter or just ask for help in this issue.

  4. Don’t forget to write a test code!

  5. 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.

  6. Submit a pull-request to the master branch.

Note that you will need a GPU environment to develop CuPy.

See also:

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:13
  • Comments:16 (14 by maintainers)

github_iconTop GitHub Comments

3reactions
kmaehashicommented, Nov 20, 2021

@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.

3reactions
rgommerscommented, Nov 19, 2021

loads and ndfromtxt were already removed in https://github.com/numpy/numpy/pull/19615, so can be removed from the list.

The medium & medium to hard seem ok though (with the exception of the typing stuff)

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.

The iterating functions (particularly on GPUs) I’m not sure about, but maybe Leo has thoughts there.

Anything else stick out to you, Ralf? Does the above sound roughly correct to you or are there other things that stick out?

That sounds about right. The random and linalg stuff is important, as are some of the medium-hard functions like put_along_axis, nanquantile, nanpercentile, etc.

All of the undocumented ones I’d like to get rid of in NumPy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

latest PDF - CuPy Documentation
CuPy is a NumPy/SciPy-compatible array library for GPU-accelerated computing with Python. CuPy acts as a drop-in replacement to run existing NumPy/SciPy ...
Read more >
Introduction to CuPy - NumPy on the GPU - YouTube
In this CuPy Tutorial, We'll take a look at CuPy and have a short introduction. CuPy is basically numpy on the GPU and...
Read more >
NEP 47 — Adopting the array API standard - NumPy
Implementing this as a separate new namespace in NumPy will allow authors of libraries which depend on NumPy as well as end users...
Read more >
2021 report - Python Data APIs Consortium
dard in NumPy. 23/08/2021. Announcement of the dataframe interchange protocol. 24/08/2021. September 2021. CuPy implementation of the Array. API standard.
Read more >
NumPy Support — pint 0.10.1 documentation
All usual Pint methods can be used with this quantity. ... that is, an array-like type that implements (all or most of) NumPy's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found