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

GH-44229: [Docs] Add PyArrow to JAX example to the docs #44230

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
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
18 changes: 14 additions & 4 deletions docs/source/python/dlpack.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ PyArrow implements the second part of the protocol
(``__dlpack__(self, stream=None)`` and ``__dlpack_device__``) and can
thus be consumed by libraries implementing ``from_dlpack``.

Example
-------
Examples
--------

Convert a PyArrow CPU array to NumPy array:
Convert a PyArrow CPU array into a NumPy array:

.. code-block::

Expand All @@ -84,10 +84,20 @@ Convert a PyArrow CPU array to NumPy array:
>>> np.from_dlpack(array)
array([2, 0, 2, 4])

Convert a PyArrow CPU array to PyTorch tensor:
Convert a PyArrow CPU array into a PyTorch tensor:

.. code-block::

>>> import torch
>>> torch.from_dlpack(array)
tensor([2, 0, 2, 4])

Convert a PyArrow CPU array into a JAX array:

.. code-block::

>>> import jax
>>> jax.numpy.from_dlpack(array)
Array([2, 0, 2, 4], dtype=int32)
>>> jax.dlpack.from_dlpack(array)
Array([2, 0, 2, 4], dtype=int32)
Loading