Skip to main content

set_graph_output_vector

Function set_graph_output_vector 

Source
pub unsafe fn set_graph_output_vector(
    output_vector: *mut mlx_vector_array,
    graph_outputs: &[&MlxArray],
) -> c_int
Expand description

Appends one lazy output to a multi-output graph’s result vector.

MLX appends through the vector’s context pointer, so pass-by-value still mutates the caller’s vector; the pointer is dereferenced once for the copy. Publishes a multi-output graph’s complete ordered result vector at once.

Compiled-graph tracing hands builders an output vector whose context may still be null, and MLX’s append operation throws on that null context while its whole-vector set allocates on demand; collecting the outputs locally and publishing them once at the end of the builder is therefore the only trace- safe multi-output pattern.

§Safety

The caller must guarantee that output_vector is unique, live, and a valid mlx_vector_array destination for the whole call.