Skip to main content

M_newWeightsRegistry

Function M_newWeightsRegistry 

Source
pub unsafe extern "C" fn M_newWeightsRegistry(
    names: *mut *const c_char,
    data: *mut *const c_void,
    numWeights: usize,
    status: *mut M_Status,
) -> *mut M_WeightsRegistry
Expand description

Creates a weights registry from parallel arrays of weight names and data pointers.

The weights registry maps weight names to their backing data. It is used with M_initModel() to provide weight data for models that use external weights (via constant_external in the graph).

The data pointers are borrowed, not copied. You must keep the backing memory alive for the lifetime of the weights registry.

@param names An array of null-terminated weight name strings. @param data An array of pointers to weight data buffers. Each entry corresponds to the weight name at the same index in names. @param numWeights The number of entries in the names and data arrays. @param status The status object for reporting errors.

@returns A pointer to the weights registry. You are responsible for the memory associated with the pointer returned. The memory can be deallocated by calling M_freeWeightsRegistry(). Returns NULL if creation fails, with an error message in status.