Skip to main content

hurray_tensor_buffers

Function hurray_tensor_buffers 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_tensor_buffers( handle: *const HurrayTensor, out_buffers: *mut *mut HurrayBufferList, ) -> HurrayStatus
Expand description

Borrows the tensor’s buffer list.

Element i of the list is buffer i of the descriptor’s buffer table. The list is borrowed: the caller MUST NOT call hurray_buffer_list_destroy on it, and MUST keep the tensor alive while it reads the buffers.

§Safety

handle and out_buffers MUST be valid, non-null pointers.

§Examples

use hurray_ffi::buffer_list::hurray_buffer_list_len;
use hurray_ffi::tensor::{hurray_tensor_buffers, hurray_tensor_destroy, hurray_tensor_new};
use hurray_ffi::{
    hurray_buffer_list_new, HurrayBufferList, HurrayTensor, HURRAY_C_ABI_VERSION, HURRAY_OK,
};
let mut borrowed: *mut HurrayBufferList = std::ptr::null_mut();
assert_eq!(
    unsafe { hurray_tensor_buffers(tensor, &mut borrowed) },
    HURRAY_OK,
);

let mut len: u64 = 0;
unsafe { hurray_buffer_list_len(borrowed, &mut len) };