Skip to main content

hurray_descriptor_shape

Function hurray_descriptor_shape 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn hurray_descriptor_shape( handle: *const HurrayDescriptor, out_dims: *mut u64, out_rank: *mut usize, ) -> HurrayStatus
Expand description

Reads the shape (dimension sizes) of a tensor descriptor.

This function uses a capacity/length in-out pattern:

  1. Set *out_rank to the capacity of the out_dims array (number of uint64_t elements it can hold), or to 0 if out_dims is null.
  2. On return, *out_rank always contains the true rank of the tensor.
  3. If out_dims is null OR the capacity was less than the true rank, the function returns HURRAY_ERR_BUFFER_TOO_SMALL and *out_rank contains the true rank so the caller can allocate and retry.
  4. Otherwise the function writes the dimension sizes into out_dims[0..rank] and returns HURRAY_OK.

§Safety

  • handle and out_rank MUST be valid, non-null pointers.
  • If out_dims is non-null it MUST be writable for capacity × 8 bytes, where capacity is the value at *out_rank on entry.