-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Tensor from_raw_parts #198
Conversation
crates/kornia-tensor/src/storage.rs
Outdated
// Safety: | ||
// TensorStorage is thread safe if the allocator is thread safe. | ||
unsafe impl<T, A: TensorAllocator> Send for TensorStorage<T, A> {} | ||
unsafe impl<T, A: TensorAllocator> Sync for TensorStorage<T, A> {} | ||
|
||
impl<T, A: TensorAllocator> Drop for TensorStorage<T, A> { | ||
fn drop(&mut self) { | ||
self.alloc | ||
.dealloc(self.ptr.as_ptr() as *mut u8, self.layout); | ||
if !self.managed_by_external { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gbin had to add this flag here to prevent double deallocation as I couldn't find a way to prevent gstreamer deallocating the memory
return Ok(None); | ||
}; | ||
|
||
let frame_buffer = std::mem::ManuallyDrop::new(frame_buffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gbin having a bit of trouble by trying to prevent gstreamer to deallocate the buffer. Do you have any insights here ?
|
||
// Check for null pointer | ||
if !ptr.is_null() { | ||
//unsafe { alloc::dealloc(ptr, layout) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gbin by commenting this line seems to do the job but i don't think it's correct. The behavior I'm seeing is that I never enter in this branch statement but gstreamer tries to allocate an invalid pointer. A bit weird -- might be missing something fundamental ?
No description provided.