Skip to content

Conversation

@HaoZeke
Copy link
Member

@HaoZeke HaoZeke commented Oct 27, 2025

Some stuff I ended up dumping. Might not be needed, driven by metatensor/metatensor#981

/// The caller must ensure that the returned pointer does not outlive
/// this `DLPackTensor` wrapper. The caller must not call the `deleter`
/// function on this pointer, as the wrapper will do so on drop.
pub fn as_mut_ptr(&self) -> *mut sys::DLManagedTensorVersioned {
Copy link
Member

Choose a reason for hiding this comment

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

this is very unsound =) It should at least take &mut self, otherwise one could get two mut pointers to the same underlying data, but I'd prefer having this function return a &mut sys::DLManagedTensorVersioned instead, so we get full lifetime tracking.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I'm not sure what's the use case is. If we want to give access to the data but not ownership, DLManagedTensorVersioned is the wrong type, that would be the job of DLTensor instead.

Copy link
Member

Choose a reason for hiding this comment

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

Also, I'm not sure what's the use case is. If we want to give access to the data but not ownership, DLManagedTensorVersioned is the wrong type, that would be the job of DLTensor instead.

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.

3 participants