Skip to content

Commit a7900c5

Browse files
HaoZekeLuthaf
authored andcommitted
feat(pubapi): add into_raw for DLPackTensor
1 parent 9d62e0b commit a7900c5

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ impl DLPackTensor {
203203
&self.raw.as_ref().dl_tensor
204204
}
205205
}
206+
207+
/// Consumes the `DLPackTensor`, returning the underlying raw pointer.
208+
///
209+
/// # Safety
210+
///
211+
/// The caller is responsible for managing the memory and calling the deleter
212+
/// when the tensor is no longer needed.
213+
pub fn into_raw(self) -> NonNull<sys::DLManagedTensorVersioned>{
214+
let raw = self.raw;
215+
// forget so Drop and ergo the deleter are not called
216+
std::mem::forget(self);
217+
return raw;
218+
}
206219
}
207220

208221
/// A reference to a DLPack tensor, with data borrowed from some owner,

0 commit comments

Comments
 (0)