Skip to content

Conversation

Enigmatisms
Copy link

@Enigmatisms Enigmatisms commented Jul 5, 2025

PR Type

Enhancement

Related topics

nb::ndarray

Intro

Hi! I’m a researcher from the PaddlePaddle team. After our conversation at SIGGRAPH Asia 2024 (where you recommended migrating from pybind11 to nanobind), I gave nanobind a try and was impressed by its performance. As part of this effort, I’ve extended nb::ndarray to support paddle.Tensor, allowing direct return of PaddlePaddle tensors from C++ via nb::paddle.

This PR includes:

  • ​​New nb::paddle​​: Mirroring nb::pytorch’s behavior, with modifications in nb_ndarray.cpp for consistent tensor handling.
  • ​​Unit tests​​: Adapted from existing PyTorch tests (using @needs_torch) to validate PaddlePaddle integration.
  • ​​Documentation​​: Added usage guidelines for nb::paddle (preview welcome—I’m unsure how it renders on the website).
  • Removed some unnecessary semicolons in the test_ndarray.py.

This change maintains backward compatibility while enabling PaddlePaddle users to leverage nanobind’s efficiency. Looking forward to feedback!


@needs_paddle
def test60_check_paddle():
assert t.check(paddle.zeros((1)).cpu())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.cpu() can actually be removed. Other parts are fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant