Skip to content

nanobind uses uses unversioned DLManagedTensor which lacks writable flag #1122

@lahwaacz

Description

@lahwaacz

Problem description

nanobind uses an "unversioned" managed_dltensor struct which corresponds to the legacy DLManagedTensor:

struct managed_dltensor {
dlpack::dltensor dltensor;
void *manager_ctx;
void (*deleter)(managed_dltensor *);
};

This lacks the flags attribute that is present in the DLManagedTensorVersioned struct:

https://github.com/dmlc/dlpack/blob/7f393bbb86a0ddd71fde3e700fc2affa5cdce72d/include/dlpack/dlpack.h#L349-L360

An important flag is DLPACK_FLAG_BITMASK_READ_ONLY which indicates if the array is read-only or writable.

Since numpy/numpy#28600 NumPy's from_dlpack function sets readonly = 1 for unversioned DLPacks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions