-
Notifications
You must be signed in to change notification settings - Fork 252
Open
Description
Hello! Just started using nanobind.
- Is there a way to allocate
nb::ndarray
using nanobind? - Is it possible to return the same type of
nb::ndarray
as was passed in, i.e. functionality similar tonp.empty_like
with exact library (numpy, torch, etc.)? An example in documentation would be nice. - I'm getting this error with the following code
RuntimeError: nanobind::detail::ndarray_export(): copy failed: AttributeError: 'PyCapsule' object has no attribute 'copy'
. (linux, python 3.13). Is the problem on my side?
#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
namespace nb = nanobind;
using Image2D = nb::ndarray<float, nb::shape<-1, -1>, nb::device::cpu>;
Image2D test(Image2D &image) {
Image2D output(nullptr, {10, 30});
return output;
}
NB_MODULE(libadrt, m) { m.def("test", &test); }
Thanks
Metadata
Metadata
Assignees
Labels
No labels