Skip to content

Commit e65c393

Browse files
committed
Add support to ndarray for DLPack version 1
1 parent db637da commit e65c393

File tree

10 files changed

+783
-241
lines changed

10 files changed

+783
-241
lines changed

include/nanobind/nb_lib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ NB_CORE PyObject *capsule_new(const void *ptr, const char *name,
277277
struct func_data_prelim_base;
278278

279279
/// Create a Python function object for the given function record
280-
NB_CORE PyObject *nb_func_new(const func_data_prelim_base *data) noexcept;
280+
NB_CORE PyObject *nb_func_new(const func_data_prelim_base *f) noexcept;
281281

282282
// ========================================================================
283283

@@ -472,7 +472,7 @@ NB_CORE ndarray_handle *ndarray_import(PyObject *o,
472472
cleanup_list *cleanup) noexcept;
473473

474474
// Describe a local ndarray object using a DLPack capsule
475-
NB_CORE ndarray_handle *ndarray_create(void *value, size_t ndim,
475+
NB_CORE ndarray_handle *ndarray_create(void *data, size_t ndim,
476476
const size_t *shape, PyObject *owner,
477477
const int64_t *strides,
478478
dlpack::dtype dtype, bool ro,

include/nanobind/ndarray.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,16 @@
1818

1919
NAMESPACE_BEGIN(NB_NAMESPACE)
2020

21-
/// dlpack API/ABI data structures are part of a separate namespace
21+
/// DLPack API/ABI data structures are part of a separate namespace.
2222
NAMESPACE_BEGIN(dlpack)
2323

2424
enum class dtype_code : uint8_t {
25-
Int = 0, UInt = 1, Float = 2, Bfloat = 4, Complex = 5, Bool = 6
25+
Int = 0, UInt = 1, Float = 2, Bfloat = 4, Complex = 5, Bool = 6,
26+
Float8_e3m4 = 7, Float8_e4m3 = 8, Float8_e4m3b11fnuz = 9,
27+
Float8_e4m3fn = 10, Float8_e4m3fnuz = 11, Float8_e5m2 = 12,
28+
Float8_e5m2fnuz = 13, Float8_e8m0fnu = 14,
29+
Float6_e2m3fn = 15, Float6_e3m2fn = 16,
30+
Float4_e2m1fn = 17
2631
};
2732

2833
struct device {
@@ -86,6 +91,7 @@ NB_FRAMEWORK(tensorflow, 3, "tensorflow.python.framework.ops.EagerTensor");
8691
NB_FRAMEWORK(jax, 4, "jaxlib.xla_extension.DeviceArray");
8792
NB_FRAMEWORK(cupy, 5, "cupy.ndarray");
8893
NB_FRAMEWORK(memview, 6, "memoryview");
94+
NB_FRAMEWORK(arrayapi, 7, "object");
8995

9096
NAMESPACE_BEGIN(device)
9197
NB_DEVICE(none, 0); NB_DEVICE(cpu, 1); NB_DEVICE(cuda, 2);

0 commit comments

Comments
 (0)