ollama source for Momentry Core verification

This commit is contained in:
Accusys
2026-05-22 17:19:10 +08:00
commit 0b31ff9135
2020 changed files with 1413145 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
# Vendored MLX-C Headers
These header files are vendored from [mlx-c](https://github.com/ml-explore/mlx-c).
The pinned version is in `MLX_C_VERSION` at the repo root.
Headers are automatically refreshed when you run a CMake build:
```shell
cmake --preset 'MLX CUDA 13'
```
See the [MLX Engine](../../../../../../../docs/development.md#mlx-engine-optional) section of the development docs for full build instructions.

View File

@@ -0,0 +1,420 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_ARRAY_H
#define MLX_ARRAY_H
#include "mlx/c/string.h"
#include <float.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
// Complex number support
#ifdef _MSC_VER
#define _CRT_USE_C_COMPLEX_H
#include <complex.h>
typedef _Fcomplex mlx_complex64_t;
#else
#include <complex.h>
typedef float _Complex mlx_complex64_t;
#endif
#include "half.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_array Array
* MLX N-dimensional array object.
*/
/**@{*/
/**
* A N-dimensional array object.
*/
typedef struct mlx_array_ {
void* ctx;
} mlx_array;
static mlx_array mlx_array_empty;
/**
* Array element type.
*/
typedef enum mlx_dtype_ {
MLX_BOOL,
MLX_UINT8,
MLX_UINT16,
MLX_UINT32,
MLX_UINT64,
MLX_INT8,
MLX_INT16,
MLX_INT32,
MLX_INT64,
MLX_FLOAT16,
MLX_FLOAT32,
MLX_FLOAT64,
MLX_BFLOAT16,
MLX_COMPLEX64,
} mlx_dtype;
/**
* Size of given mlx_dtype datatype in bytes.
*/
size_t mlx_dtype_size(mlx_dtype dtype);
/**
* Get array description.
*/
int mlx_array_tostring(mlx_string* str, const mlx_array arr);
/**
* New empty array.
*/
mlx_array mlx_array_new(void);
/**
* Free an array.
*/
int mlx_array_free(mlx_array arr);
/**
* New array from a bool scalar.
*/
mlx_array mlx_array_new_bool(bool val);
/**
* New array from a int scalar.
*/
mlx_array mlx_array_new_int(int val);
/**
* New array from a float32 scalar.
*/
mlx_array mlx_array_new_float32(float val);
/**
* New array from a float scalar.
* Same as float32.
*/
mlx_array mlx_array_new_float(float val);
/**
* New array from a float64 scalar.
*/
mlx_array mlx_array_new_float64(double val);
/**
* New array from a double scalar.
* Same as float64.
*/
mlx_array mlx_array_new_double(double val);
/**
* New array from a complex scalar.
*/
mlx_array mlx_array_new_complex(float real_val, float imag_val);
/**
* New array from existing buffer.
* @param data A buffer which will be copied.
* @param shape Shape of the array.
* @param dim Number of dimensions (size of `shape`).
* @param dtype Type of array elements.
*/
mlx_array mlx_array_new_data(
const void* data,
const int* shape,
int dim,
mlx_dtype dtype);
/**
* New array from existing buffer.
* @param data A buffer which will be copied.
* @param shape Shape of the array.
* @param dim Number of dimensions (size of `shape`).
* @param dtype Type of array elements.
* @param dtor Callback for when the buffer is no longer needed.
*/
mlx_array mlx_array_new_data_managed(
void* data,
const int* shape,
int dim,
mlx_dtype dtype,
void (*dtor)(void*));
/**
* New array from existing buffer.
* @param data A buffer which will be copied.
* @param shape Shape of the array.
* @param dim Number of dimensions (size of `shape`).
* @param dtype Type of array elements.
* @param payload Payload pointer passed to the `dtor` callback instead of
* `data`.
* @param dtor Callback for when the buffer is no longer needed.
*/
mlx_array mlx_array_new_data_managed_payload(
void* data,
const int* shape,
int dim,
mlx_dtype dtype,
void* payload,
void (*dtor)(void*));
/**
* Set array to provided src array.
*/
int mlx_array_set(mlx_array* arr, const mlx_array src);
/**
* Set array to a bool scalar.
*/
int mlx_array_set_bool(mlx_array* arr, bool val);
/**
* Set array to a int scalar.
*/
int mlx_array_set_int(mlx_array* arr, int val);
/**
* Set array to a float32 scalar.
*/
int mlx_array_set_float32(mlx_array* arr, float val);
/**
* Set array to a float scalar.
*/
int mlx_array_set_float(mlx_array* arr, float val);
/**
* Set array to a float64 scalar.
*/
int mlx_array_set_float64(mlx_array* arr, double val);
/**
* Set array to a double scalar.
*/
int mlx_array_set_double(mlx_array* arr, double val);
/**
* Set array to a complex scalar.
*/
int mlx_array_set_complex(mlx_array* arr, float real_val, float imag_val);
/**
* Set array to specified data and shape.
* @param arr Destination array.
* @param data A buffer which will be copied.
* @param shape Shape of the array.
* @param dim Number of dimensions (size of `shape`).
* @param dtype Type of array elements.
*/
int mlx_array_set_data(
mlx_array* arr,
const void* data,
const int* shape,
int dim,
mlx_dtype dtype);
/**
* The size of the array's datatype in bytes.
*/
size_t mlx_array_itemsize(const mlx_array arr);
/**
* Number of elements in the array.
*/
size_t mlx_array_size(const mlx_array arr);
/**
* The number of bytes in the array.
*/
size_t mlx_array_nbytes(const mlx_array arr);
/**
* The array's dimension.
*/
size_t mlx_array_ndim(const mlx_array arr);
/**
* The shape of the array.
* Returns: a pointer to the sizes of each dimension.
*/
const int* mlx_array_shape(const mlx_array arr);
/**
* The strides of the array.
* Returns: a pointer to the sizes of each dimension.
*/
const size_t* mlx_array_strides(const mlx_array arr);
/**
* The shape of the array in a particular dimension.
*/
int mlx_array_dim(const mlx_array arr, int dim);
/**
* The array element type.
*/
mlx_dtype mlx_array_dtype(const mlx_array arr);
/**
* Evaluate the array.
*/
int mlx_array_eval(mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_bool(bool* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_uint8(uint8_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_uint16(uint16_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_uint32(uint32_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_uint64(uint64_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_int8(int8_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_int16(int16_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_int32(int32_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_int64(int64_t* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_float32(float* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_float64(double* res, const mlx_array arr);
/**
* Access the value of a scalar array.
*/
int mlx_array_item_complex64(mlx_complex64_t* res, const mlx_array arr);
#ifdef HAS_FLOAT16
/**
* Access the value of a scalar array.
*/
int mlx_array_item_float16(float16_t* res, const mlx_array arr);
#endif
#ifdef HAS_BFLOAT16
/**
* Access the value of a scalar array.
*/
int mlx_array_item_bfloat16(bfloat16_t* res, const mlx_array arr);
#endif
/**
* Returns a pointer to the array data, cast to `bool*`.
* Array must be evaluated, otherwise returns NULL.
*/
const bool* mlx_array_data_bool(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `uint8_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const uint8_t* mlx_array_data_uint8(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `uint16_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const uint16_t* mlx_array_data_uint16(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `uint32_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const uint32_t* mlx_array_data_uint32(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `uint64_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const uint64_t* mlx_array_data_uint64(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `int8_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const int8_t* mlx_array_data_int8(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `int16_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const int16_t* mlx_array_data_int16(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `int32_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const int32_t* mlx_array_data_int32(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `int64_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const int64_t* mlx_array_data_int64(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `float32*`.
* Array must be evaluated, otherwise returns NULL.
*/
const float* mlx_array_data_float32(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `float64*`.
* Array must be evaluated, otherwise returns NULL.
*/
const double* mlx_array_data_float64(const mlx_array arr);
/**
* Returns a pointer to the array data, cast to `_Complex*`.
* Array must be evaluated, otherwise returns NULL.
*/
const mlx_complex64_t* mlx_array_data_complex64(const mlx_array arr);
#ifdef HAS_FLOAT16
/**
* Returns a pointer to the array data, cast to `float16_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const float16_t* mlx_array_data_float16(const mlx_array arr);
#endif
#ifdef HAS_BFLOAT16
/**
* Returns a pointer to the array data, cast to `bfloat16_t*`.
* Array must be evaluated, otherwise returns NULL.
*/
const bfloat16_t* mlx_array_data_bfloat16(const mlx_array arr);
#endif
/**
* Check if the array is available.
* Internal function: use at your own risk.
*/
int _mlx_array_is_available(bool* res, const mlx_array arr);
/**
* Wait on the array to be available. After this `_mlx_array_is_available`
* returns `true`. Internal function: use at your own risk.
*/
int _mlx_array_wait(const mlx_array arr);
/**
* Whether the array is contiguous in memory.
* Internal function: use at your own risk.
*/
int _mlx_array_is_contiguous(bool* res, const mlx_array arr);
/**
* Whether the array's rows are contiguous in memory.
* Internal function: use at your own risk.
*/
int _mlx_array_is_row_contiguous(bool* res, const mlx_array arr);
/**
* Whether the array's columns are contiguous in memory.
* Internal function: use at your own risk.
*/
int _mlx_array_is_col_contiguous(bool* res, const mlx_array arr);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,197 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_CLOSURE_H
#define MLX_CLOSURE_H
#include "mlx/c/array.h"
#include "mlx/c/map.h"
#include "mlx/c/optional.h"
#include "mlx/c/stream.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_closure Closures
* MLX closure objects.
*/
/**@{*/
typedef struct mlx_closure_ {
void* ctx;
} mlx_closure;
mlx_closure mlx_closure_new(void);
int mlx_closure_free(mlx_closure cls);
mlx_closure mlx_closure_new_func(
int (*fun)(mlx_vector_array*, const mlx_vector_array));
mlx_closure mlx_closure_new_func_payload(
int (*fun)(mlx_vector_array*, const mlx_vector_array, void*),
void* payload,
void (*dtor)(void*));
int mlx_closure_set(mlx_closure* cls, const mlx_closure src);
int mlx_closure_apply(
mlx_vector_array* res,
mlx_closure cls,
const mlx_vector_array input);
mlx_closure mlx_closure_new_unary(int (*fun)(mlx_array*, const mlx_array));
typedef struct mlx_closure_kwargs_ {
void* ctx;
} mlx_closure_kwargs;
mlx_closure_kwargs mlx_closure_kwargs_new(void);
int mlx_closure_kwargs_free(mlx_closure_kwargs cls);
mlx_closure_kwargs mlx_closure_kwargs_new_func(
int (*fun)(
mlx_vector_array*,
const mlx_vector_array,
const mlx_map_string_to_array));
mlx_closure_kwargs mlx_closure_kwargs_new_func_payload(
int (*fun)(
mlx_vector_array*,
const mlx_vector_array,
const mlx_map_string_to_array,
void*),
void* payload,
void (*dtor)(void*));
int mlx_closure_kwargs_set(
mlx_closure_kwargs* cls,
const mlx_closure_kwargs src);
int mlx_closure_kwargs_apply(
mlx_vector_array* res,
mlx_closure_kwargs cls,
const mlx_vector_array input_0,
const mlx_map_string_to_array input_1);
typedef struct mlx_closure_value_and_grad_ {
void* ctx;
} mlx_closure_value_and_grad;
mlx_closure_value_and_grad mlx_closure_value_and_grad_new(void);
int mlx_closure_value_and_grad_free(mlx_closure_value_and_grad cls);
mlx_closure_value_and_grad mlx_closure_value_and_grad_new_func(
int (*fun)(mlx_vector_array*, mlx_vector_array*, const mlx_vector_array));
mlx_closure_value_and_grad mlx_closure_value_and_grad_new_func_payload(
int (*fun)(
mlx_vector_array*,
mlx_vector_array*,
const mlx_vector_array,
void*),
void* payload,
void (*dtor)(void*));
int mlx_closure_value_and_grad_set(
mlx_closure_value_and_grad* cls,
const mlx_closure_value_and_grad src);
int mlx_closure_value_and_grad_apply(
mlx_vector_array* res_0,
mlx_vector_array* res_1,
mlx_closure_value_and_grad cls,
const mlx_vector_array input);
typedef struct mlx_closure_custom_ {
void* ctx;
} mlx_closure_custom;
mlx_closure_custom mlx_closure_custom_new(void);
int mlx_closure_custom_free(mlx_closure_custom cls);
mlx_closure_custom mlx_closure_custom_new_func(
int (*fun)(
mlx_vector_array*,
const mlx_vector_array,
const mlx_vector_array,
const mlx_vector_array));
mlx_closure_custom mlx_closure_custom_new_func_payload(
int (*fun)(
mlx_vector_array*,
const mlx_vector_array,
const mlx_vector_array,
const mlx_vector_array,
void*),
void* payload,
void (*dtor)(void*));
int mlx_closure_custom_set(
mlx_closure_custom* cls,
const mlx_closure_custom src);
int mlx_closure_custom_apply(
mlx_vector_array* res,
mlx_closure_custom cls,
const mlx_vector_array input_0,
const mlx_vector_array input_1,
const mlx_vector_array input_2);
typedef struct mlx_closure_custom_jvp_ {
void* ctx;
} mlx_closure_custom_jvp;
mlx_closure_custom_jvp mlx_closure_custom_jvp_new(void);
int mlx_closure_custom_jvp_free(mlx_closure_custom_jvp cls);
mlx_closure_custom_jvp mlx_closure_custom_jvp_new_func(
int (*fun)(
mlx_vector_array*,
const mlx_vector_array,
const mlx_vector_array,
const int*,
size_t _num));
mlx_closure_custom_jvp mlx_closure_custom_jvp_new_func_payload(
int (*fun)(
mlx_vector_array*,
const mlx_vector_array,
const mlx_vector_array,
const int*,
size_t _num,
void*),
void* payload,
void (*dtor)(void*));
int mlx_closure_custom_jvp_set(
mlx_closure_custom_jvp* cls,
const mlx_closure_custom_jvp src);
int mlx_closure_custom_jvp_apply(
mlx_vector_array* res,
mlx_closure_custom_jvp cls,
const mlx_vector_array input_0,
const mlx_vector_array input_1,
const int* input_2,
size_t input_2_num);
typedef struct mlx_closure_custom_vmap_ {
void* ctx;
} mlx_closure_custom_vmap;
mlx_closure_custom_vmap mlx_closure_custom_vmap_new(void);
int mlx_closure_custom_vmap_free(mlx_closure_custom_vmap cls);
mlx_closure_custom_vmap mlx_closure_custom_vmap_new_func(
int (*fun)(
mlx_vector_array*,
mlx_vector_int*,
const mlx_vector_array,
const int*,
size_t _num));
mlx_closure_custom_vmap mlx_closure_custom_vmap_new_func_payload(
int (*fun)(
mlx_vector_array*,
mlx_vector_int*,
const mlx_vector_array,
const int*,
size_t _num,
void*),
void* payload,
void (*dtor)(void*));
int mlx_closure_custom_vmap_set(
mlx_closure_custom_vmap* cls,
const mlx_closure_custom_vmap src);
int mlx_closure_custom_vmap_apply(
mlx_vector_array* res_0,
mlx_vector_int* res_1,
mlx_closure_custom_vmap cls,
const mlx_vector_array input_0,
const int* input_1,
size_t input_1_num);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,58 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_COMPILE_H
#define MLX_COMPILE_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup compile Compilation operations
*/
/**@{*/
typedef enum mlx_compile_mode_ {
MLX_COMPILE_MODE_DISABLED,
MLX_COMPILE_MODE_NO_SIMPLIFY,
MLX_COMPILE_MODE_NO_FUSE,
MLX_COMPILE_MODE_ENABLED
} mlx_compile_mode;
int mlx_compile(mlx_closure* res, const mlx_closure fun, bool shapeless);
int mlx_detail_compile(
mlx_closure* res,
const mlx_closure fun,
uintptr_t fun_id,
bool shapeless,
const uint64_t* constants,
size_t constants_num);
int mlx_detail_compile_clear_cache(void);
int mlx_detail_compile_erase(uintptr_t fun_id);
int mlx_disable_compile(void);
int mlx_enable_compile(void);
int mlx_set_compile_mode(mlx_compile_mode mode);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,39 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_CUDA_H
#define MLX_CUDA_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup cuda Cuda specific operations
*/
/**@{*/
int mlx_cuda_is_available(bool* res);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,154 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_DEVICE_H
#define MLX_DEVICE_H
#include <stdbool.h>
#include <stddef.h>
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_device Device
* MLX device object.
*/
/**@{*/
/**
* A MLX device object.
*/
typedef struct mlx_device_ {
void* ctx;
} mlx_device;
/**
* Device type.
*/
typedef enum mlx_device_type_ { MLX_CPU, MLX_GPU } mlx_device_type;
/**
* Returns a new empty device.
*/
mlx_device mlx_device_new(void);
/**
* Returns a new device of specified `type`, with specified `index`.
*/
mlx_device mlx_device_new_type(mlx_device_type type, int index);
/**
* Free a device.
*/
int mlx_device_free(mlx_device dev);
/**
* Set device to provided src device.
*/
int mlx_device_set(mlx_device* dev, const mlx_device src);
/**
* Get device description.
*/
int mlx_device_tostring(mlx_string* str, mlx_device dev);
/**
* Check if devices are the same.
*/
bool mlx_device_equal(mlx_device lhs, mlx_device rhs);
/**
* Returns the index of the device.
*/
int mlx_device_get_index(int* index, mlx_device dev);
/**
* Returns the type of the device.
*/
int mlx_device_get_type(mlx_device_type* type, mlx_device dev);
/**
* Returns the default MLX device.
*/
int mlx_get_default_device(mlx_device* dev);
/**
* Set the default MLX device.
*/
int mlx_set_default_device(mlx_device dev);
/**
* Check if device is available.
*/
int mlx_device_is_available(bool* avail, mlx_device dev);
/**
* Get the number of available devices for a device type.
*/
int mlx_device_count(int* count, mlx_device_type type);
/**
* A MLX device info object.
* Contains key-value pairs with device properties.
* Keys vary by backend but common keys include:
* - device_name (string): Device name
* - architecture (string): Architecture identifier
* Additional keys may be present depending on the backend.
*/
typedef struct mlx_device_info_ {
void* ctx;
} mlx_device_info;
/**
* Returns a new empty device info object.
*/
mlx_device_info mlx_device_info_new(void);
/**
* Get device information for a device.
*/
int mlx_device_info_get(mlx_device_info* info, mlx_device dev);
/**
* Free a device info object.
*/
int mlx_device_info_free(mlx_device_info info);
/**
* Check if a key exists in the device info.
* Returns 0 on success, 1 on error.
* Sets *exists to true if the key exists, false otherwise.
*/
int mlx_device_info_has_key(
bool* exists,
mlx_device_info info,
const char* key);
/**
* Check if a value is a string type.
* Returns 0 on success, 1 on error.
* Sets *is_string to true if the value is a string, false if it's a size_t.
*/
int mlx_device_info_is_string(
bool* is_string,
mlx_device_info info,
const char* key);
/**
* Get a string value from device info.
* Returns 0 on success, 1 on error, 2 if key not found or wrong type.
*/
int mlx_device_info_get_string(
const char** value,
mlx_device_info info,
const char* key);
/**
* Get a size_t value from device info.
* Returns 0 on success, 1 on error, 2 if key not found or wrong type.
*/
int mlx_device_info_get_size(
size_t* value,
mlx_device_info info,
const char* key);
/**
* Get all keys from device info.
* Returns 0 on success, 1 on error.
*/
int mlx_device_info_get_keys(mlx_vector_string* keys, mlx_device_info info);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,83 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_DISTRIBUTED_H
#define MLX_DISTRIBUTED_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup distributed Distributed collectives
*/
/**@{*/
int mlx_distributed_all_gather(
mlx_array* res,
const mlx_array x,
const mlx_distributed_group group /* may be null */,
const mlx_stream S);
int mlx_distributed_all_max(
mlx_array* res,
const mlx_array x,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
int mlx_distributed_all_min(
mlx_array* res,
const mlx_array x,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
int mlx_distributed_all_sum(
mlx_array* res,
const mlx_array x,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
int mlx_distributed_recv(
mlx_array* res,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
int src,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
int mlx_distributed_recv_like(
mlx_array* res,
const mlx_array x,
int src,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
int mlx_distributed_send(
mlx_array* res,
const mlx_array x,
int dst,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
int mlx_distributed_sum_scatter(
mlx_array* res,
const mlx_array x,
const mlx_distributed_group group /* may be null */,
const mlx_stream s);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,74 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_DISTRIBUTED_GROUP_H
#define MLX_DISTRIBUTED_GROUP_H
#include <stdbool.h>
#include "mlx/c/stream.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_distributed_group MLX distributed
*/
/**@{*/
/**
* A MLX distributed group object.
*/
typedef struct mlx_distributed_group_ {
void* ctx;
} mlx_distributed_group;
/**
* Create an empty group.
*/
mlx_distributed_group mlx_distributed_group_new(void);
/**
* Free the group.
*/
int mlx_distributed_group_free(mlx_distributed_group group);
/**
* Initialize distributed.
*/
int mlx_distributed_init(
mlx_distributed_group* res,
bool strict,
const char* bk /* may be null */);
/**
* Get the rank.
*/
int mlx_distributed_group_rank(mlx_distributed_group group);
/**
* Get the group size.
*/
int mlx_distributed_group_size(mlx_distributed_group group);
/**
* Split the group.
*/
int mlx_distributed_group_split(
mlx_distributed_group* res,
mlx_distributed_group group,
int color,
int key);
/**
* Check if distributed is available.
*/
bool mlx_distributed_is_available(const char* bk /* may be null */);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,41 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_ERROR_H
#define MLX_ERROR_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_error Error management
*/
/**@{*/
typedef void (*mlx_error_handler_func)(const char* msg, void* data);
/**
* Set the error handler.
*/
void mlx_set_error_handler(
mlx_error_handler_func handler,
void* data,
void (*dtor)(void*));
/**
* Throw an error.
*/
void _mlx_error(const char* file, const int line, const char* fmt, ...);
/**
* Throw an error. Macro which passes file name and line number to _mlx_error().
*/
#define mlx_error(...) _mlx_error(__FILE__, __LINE__, __VA_ARGS__)
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,75 @@
/* Copyright © 2023-2025 Apple Inc. */
#ifndef MLX_EXPORT_H
#define MLX_EXPORT_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup export Function serialization
*/
/**@{*/
int mlx_export_function(
const char* file,
const mlx_closure fun,
const mlx_vector_array args,
bool shapeless);
int mlx_export_function_kwargs(
const char* file,
const mlx_closure_kwargs fun,
const mlx_vector_array args,
const mlx_map_string_to_array kwargs,
bool shapeless);
typedef struct mlx_function_exporter_ {
void* ctx;
} mlx_function_exporter;
mlx_function_exporter mlx_function_exporter_new(
const char* file,
const mlx_closure fun,
bool shapeless);
int mlx_function_exporter_free(mlx_function_exporter xfunc);
int mlx_function_exporter_apply(
const mlx_function_exporter xfunc,
const mlx_vector_array args);
int mlx_function_exporter_apply_kwargs(
const mlx_function_exporter xfunc,
const mlx_vector_array args,
const mlx_map_string_to_array kwargs);
typedef struct mlx_imported_function_ {
void* ctx;
} mlx_imported_function;
mlx_imported_function mlx_imported_function_new(const char* file);
int mlx_imported_function_free(mlx_imported_function xfunc);
int mlx_imported_function_apply(
mlx_vector_array* res,
const mlx_imported_function xfunc,
const mlx_vector_array args);
int mlx_imported_function_apply_kwargs(
mlx_vector_array* res,
const mlx_imported_function xfunc,
const mlx_vector_array args,
const mlx_map_string_to_array kwargs);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,206 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_FAST_H
#define MLX_FAST_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup fast Fast custom operations
*/
/**@{*/
typedef struct mlx_fast_cuda_kernel_config_ {
void* ctx;
} mlx_fast_cuda_kernel_config;
mlx_fast_cuda_kernel_config mlx_fast_cuda_kernel_config_new(void);
void mlx_fast_cuda_kernel_config_free(mlx_fast_cuda_kernel_config cls);
int mlx_fast_cuda_kernel_config_add_output_arg(
mlx_fast_cuda_kernel_config cls,
const int* shape,
size_t size,
mlx_dtype dtype);
int mlx_fast_cuda_kernel_config_set_grid(
mlx_fast_cuda_kernel_config cls,
int grid1,
int grid2,
int grid3);
int mlx_fast_cuda_kernel_config_set_thread_group(
mlx_fast_cuda_kernel_config cls,
int thread1,
int thread2,
int thread3);
int mlx_fast_cuda_kernel_config_set_init_value(
mlx_fast_cuda_kernel_config cls,
float value);
int mlx_fast_cuda_kernel_config_set_verbose(
mlx_fast_cuda_kernel_config cls,
bool verbose);
int mlx_fast_cuda_kernel_config_add_template_arg_dtype(
mlx_fast_cuda_kernel_config cls,
const char* name,
mlx_dtype dtype);
int mlx_fast_cuda_kernel_config_add_template_arg_int(
mlx_fast_cuda_kernel_config cls,
const char* name,
int value);
int mlx_fast_cuda_kernel_config_add_template_arg_bool(
mlx_fast_cuda_kernel_config cls,
const char* name,
bool value);
typedef struct mlx_fast_cuda_kernel_ {
void* ctx;
} mlx_fast_cuda_kernel;
mlx_fast_cuda_kernel mlx_fast_cuda_kernel_new(
const char* name,
const mlx_vector_string input_names,
const mlx_vector_string output_names,
const char* source,
const char* header,
bool ensure_row_contiguous,
int shared_memory);
void mlx_fast_cuda_kernel_free(mlx_fast_cuda_kernel cls);
int mlx_fast_cuda_kernel_apply(
mlx_vector_array* outputs,
mlx_fast_cuda_kernel cls,
const mlx_vector_array inputs,
const mlx_fast_cuda_kernel_config config,
const mlx_stream stream);
int mlx_fast_layer_norm(
mlx_array* res,
const mlx_array x,
const mlx_array weight /* may be null */,
const mlx_array bias /* may be null */,
float eps,
const mlx_stream s);
typedef struct mlx_fast_metal_kernel_config_ {
void* ctx;
} mlx_fast_metal_kernel_config;
mlx_fast_metal_kernel_config mlx_fast_metal_kernel_config_new(void);
void mlx_fast_metal_kernel_config_free(mlx_fast_metal_kernel_config cls);
int mlx_fast_metal_kernel_config_add_output_arg(
mlx_fast_metal_kernel_config cls,
const int* shape,
size_t size,
mlx_dtype dtype);
int mlx_fast_metal_kernel_config_set_grid(
mlx_fast_metal_kernel_config cls,
int grid1,
int grid2,
int grid3);
int mlx_fast_metal_kernel_config_set_thread_group(
mlx_fast_metal_kernel_config cls,
int thread1,
int thread2,
int thread3);
int mlx_fast_metal_kernel_config_set_init_value(
mlx_fast_metal_kernel_config cls,
float value);
int mlx_fast_metal_kernel_config_set_verbose(
mlx_fast_metal_kernel_config cls,
bool verbose);
int mlx_fast_metal_kernel_config_add_template_arg_dtype(
mlx_fast_metal_kernel_config cls,
const char* name,
mlx_dtype dtype);
int mlx_fast_metal_kernel_config_add_template_arg_int(
mlx_fast_metal_kernel_config cls,
const char* name,
int value);
int mlx_fast_metal_kernel_config_add_template_arg_bool(
mlx_fast_metal_kernel_config cls,
const char* name,
bool value);
typedef struct mlx_fast_metal_kernel_ {
void* ctx;
} mlx_fast_metal_kernel;
mlx_fast_metal_kernel mlx_fast_metal_kernel_new(
const char* name,
const mlx_vector_string input_names,
const mlx_vector_string output_names,
const char* source,
const char* header,
bool ensure_row_contiguous,
bool atomic_outputs);
void mlx_fast_metal_kernel_free(mlx_fast_metal_kernel cls);
int mlx_fast_metal_kernel_apply(
mlx_vector_array* outputs,
mlx_fast_metal_kernel cls,
const mlx_vector_array inputs,
const mlx_fast_metal_kernel_config config,
const mlx_stream stream);
int mlx_fast_rms_norm(
mlx_array* res,
const mlx_array x,
const mlx_array weight /* may be null */,
float eps,
const mlx_stream s);
int mlx_fast_rope(
mlx_array* res,
const mlx_array x,
int dims,
bool traditional,
mlx_optional_float base,
float scale,
int offset,
const mlx_array freqs /* may be null */,
const mlx_stream s);
int mlx_fast_rope_dynamic(
mlx_array* res,
const mlx_array x,
int dims,
bool traditional,
mlx_optional_float base,
float scale,
const mlx_array offset,
const mlx_array freqs /* may be null */,
const mlx_stream s);
int mlx_fast_scaled_dot_product_attention(
mlx_array* res,
const mlx_array queries,
const mlx_array keys,
const mlx_array values,
float scale,
const char* mask_mode,
const mlx_array mask_arr /* may be null */,
const mlx_array sinks /* may be null */,
const mlx_stream s);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,158 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_FFT_H
#define MLX_FFT_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup fft FFT operations
*/
/**@{*/
typedef enum mlx_fft_norm_ {
MLX_FFT_NORM_BACKWARD,
MLX_FFT_NORM_ORTHO,
MLX_FFT_NORM_FORWARD
} mlx_fft_norm;
int mlx_fft_fft(
mlx_array* res,
const mlx_array a,
int n,
int axis,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_fft2(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_fftfreq(mlx_array* res, int n, double d, const mlx_stream s);
int mlx_fft_fftn(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_fftshift(
mlx_array* res,
const mlx_array a,
const int* axes,
size_t axes_num,
const mlx_stream s);
int mlx_fft_ifft(
mlx_array* res,
const mlx_array a,
int n,
int axis,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_ifft2(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_ifftn(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_ifftshift(
mlx_array* res,
const mlx_array a,
const int* axes,
size_t axes_num,
const mlx_stream s);
int mlx_fft_irfft(
mlx_array* res,
const mlx_array a,
int n,
int axis,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_irfft2(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_irfftn(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_rfft(
mlx_array* res,
const mlx_array a,
int n,
int axis,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_rfft2(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
int mlx_fft_rfftfreq(mlx_array* res, int n, double d, const mlx_stream s);
int mlx_fft_rfftn(
mlx_array* res,
const mlx_array a,
const int* n,
size_t n_num,
const int* axes,
size_t axes_num,
mlx_fft_norm norm,
const mlx_stream s);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,61 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_GRAPH_UTILS_H
#define MLX_GRAPH_UTILS_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup graph_utils Graph Utils
*/
/**@{*/
typedef struct mlx_node_namer_ {
void* ctx;
} mlx_node_namer;
mlx_node_namer mlx_node_namer_new();
int mlx_node_namer_free(mlx_node_namer namer);
int mlx_node_namer_set_name(
mlx_node_namer namer,
const mlx_array arr,
const char* name);
int mlx_node_namer_get_name(
const char** name,
mlx_node_namer namer,
const mlx_array arr);
int mlx_export_to_dot(
FILE* os,
const mlx_node_namer namer,
const mlx_vector_array outputs);
int mlx_print_graph(
FILE* os,
const mlx_node_namer namer,
const mlx_vector_array outputs);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,26 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_HALF_H
#define MLX_HALF_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__ARM_FEATURE_FP16_SCALAR_ARITHMETIC) || defined(__aarch64__)
#define HAS_FLOAT16
#include <arm_fp16.h>
typedef __fp16 float16_t;
#endif
#if defined(__ARM_FEATURE_BF16) || defined(__aarch64__)
#define HAS_BFLOAT16
#include <arm_bf16.h>
typedef __bf16 bfloat16_t;
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,68 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_IO_H
#define MLX_IO_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup io IO operations
*/
/**@{*/
int mlx_load_reader(
mlx_array* res,
mlx_io_reader in_stream,
const mlx_stream s);
int mlx_load(mlx_array* res, const char* file, const mlx_stream s);
int mlx_load_gguf(mlx_io_gguf* gguf, const char* file, const mlx_stream s);
int mlx_load_safetensors_reader(
mlx_map_string_to_array* res_0,
mlx_map_string_to_string* res_1,
mlx_io_reader in_stream,
const mlx_stream s);
int mlx_load_safetensors(
mlx_map_string_to_array* res_0,
mlx_map_string_to_string* res_1,
const char* file,
const mlx_stream s);
int mlx_save_writer(mlx_io_writer out_stream, const mlx_array a);
int mlx_save(const char* file, const mlx_array a);
int mlx_save_gguf(const char* file, mlx_io_gguf gguf);
int mlx_save_safetensors_writer(
mlx_io_writer in_stream,
const mlx_map_string_to_array param,
const mlx_map_string_to_string metadata);
int mlx_save_safetensors(
const char* file,
const mlx_map_string_to_array param,
const mlx_map_string_to_string metadata);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,150 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_IO_TYPES_H
#define MLX_IO_TYPES_H
#include <stdbool.h>
#include "mlx/c/string.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_io_types IO Types
* MLX IO type objects.
*/
/**@{*/
/**
* A MLX IO reader object.
*/
typedef struct mlx_io_reader_ {
void* ctx;
} mlx_io_reader;
/**
* A MLX IO writer object.
*/
typedef struct mlx_io_writer_ {
void* ctx;
} mlx_io_writer;
/**
* Virtual table for custom IO reader and writer objects.
*/
typedef struct mlx_io_vtable_ {
bool (*is_open)(void*);
bool (*good)(void*);
size_t (*tell)(void*);
void (*seek)(void*, int64_t off, int whence);
void (*read)(void*, char* data, size_t n);
void (*read_at_offset)(void*, char* data, size_t n, size_t off);
void (*write)(void*, const char* data, size_t n);
const char* (*label)(void*);
void (*free)(void*);
} mlx_io_vtable;
/**
* Returns a new custom IO reader.
* `vtable` operates on user descriptor `desc`.
*/
mlx_io_reader mlx_io_reader_new(void* desc, mlx_io_vtable vtable);
/**
* Get IO reader user descriptor.
*/
int mlx_io_reader_descriptor(void** desc_, mlx_io_reader io);
/**
* Get IO reader description.
*/
int mlx_io_reader_tostring(mlx_string* str_, mlx_io_reader io);
/**
* Free IO reader.
*
* Note that MLX arrays are lazily evaluated, so the underlying object may
* be not freed right away. The ``free()`` callback from ``mlx_io_vtable``
* will be called when the underlying object is actually freed.
*/
int mlx_io_reader_free(mlx_io_reader io);
/**
* Returns a new custom IO writer.
* `vtable` operates on user descriptor `desc`.
*/
mlx_io_writer mlx_io_writer_new(void* desc, mlx_io_vtable vtable);
/**
* Get IO writer user descriptor.
*/
int mlx_io_writer_descriptor(void** desc_, mlx_io_writer io);
/**
* Get IO writer description.
*/
int mlx_io_writer_tostring(mlx_string* str_, mlx_io_writer io);
/**
* Free IO writer.
*
* Note that MLX arrays are lazily evaluated, so the underlying object may
* be not freed right away. The ``free()`` callback from ``mlx_io_vtable``
* will be called when the underlying object is actually freed.
*/
int mlx_io_writer_free(mlx_io_writer io);
/**
* A MLX GGUF object.
*/
typedef struct mlx_io_gguf_ {
void* ctx;
} mlx_io_gguf;
mlx_io_gguf mlx_io_gguf_new(void);
int mlx_io_gguf_free(mlx_io_gguf io);
int mlx_io_gguf_get_keys(mlx_vector_string* keys, mlx_io_gguf io);
int mlx_io_gguf_get_array(mlx_array* arr, mlx_io_gguf io, const char* key);
int mlx_io_gguf_get_metadata_array(
mlx_array* arr,
mlx_io_gguf io,
const char* key);
int mlx_io_gguf_get_metadata_string(
mlx_string* str,
mlx_io_gguf io,
const char* key);
int mlx_io_gguf_get_metadata_vector_string(
mlx_vector_string* vstr,
mlx_io_gguf io,
const char* key);
int mlx_io_gguf_has_metadata_array(bool* flag, mlx_io_gguf io, const char* key);
int mlx_io_gguf_has_metadata_string(
bool* flag,
mlx_io_gguf io,
const char* key);
int mlx_io_gguf_has_metadata_vector_string(
bool* flag,
mlx_io_gguf io,
const char* key);
int mlx_io_gguf_set_array(mlx_io_gguf io, const char* key, const mlx_array arr);
int mlx_io_gguf_set_metadata_array(
mlx_io_gguf io,
const char* key,
const mlx_array marr);
int mlx_io_gguf_set_metadata_string(
mlx_io_gguf io,
const char* key,
const char* mstr);
int mlx_io_gguf_set_metadata_vector_string(
mlx_io_gguf io,
const char* key,
const mlx_vector_string mvstr);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,128 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_LINALG_H
#define MLX_LINALG_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup linalg Linear algebra operations
*/
/**@{*/
int mlx_linalg_cholesky(
mlx_array* res,
const mlx_array a,
bool upper,
const mlx_stream s);
int mlx_linalg_cholesky_inv(
mlx_array* res,
const mlx_array a,
bool upper,
const mlx_stream s);
int mlx_linalg_cross(
mlx_array* res,
const mlx_array a,
const mlx_array b,
int axis,
const mlx_stream s);
int mlx_linalg_eig(
mlx_array* res_0,
mlx_array* res_1,
const mlx_array a,
const mlx_stream s);
int mlx_linalg_eigh(
mlx_array* res_0,
mlx_array* res_1,
const mlx_array a,
const char* UPLO,
const mlx_stream s);
int mlx_linalg_eigvals(mlx_array* res, const mlx_array a, const mlx_stream s);
int mlx_linalg_eigvalsh(
mlx_array* res,
const mlx_array a,
const char* UPLO,
const mlx_stream s);
int mlx_linalg_inv(mlx_array* res, const mlx_array a, const mlx_stream s);
int mlx_linalg_lu(mlx_vector_array* res, const mlx_array a, const mlx_stream s);
int mlx_linalg_lu_factor(
mlx_array* res_0,
mlx_array* res_1,
const mlx_array a,
const mlx_stream s);
int mlx_linalg_norm(
mlx_array* res,
const mlx_array a,
double ord,
const int* axis /* may be null */,
size_t axis_num,
bool keepdims,
const mlx_stream s);
int mlx_linalg_norm_matrix(
mlx_array* res,
const mlx_array a,
const char* ord,
const int* axis /* may be null */,
size_t axis_num,
bool keepdims,
const mlx_stream s);
int mlx_linalg_norm_l2(
mlx_array* res,
const mlx_array a,
const int* axis /* may be null */,
size_t axis_num,
bool keepdims,
const mlx_stream s);
int mlx_linalg_pinv(mlx_array* res, const mlx_array a, const mlx_stream s);
int mlx_linalg_qr(
mlx_array* res_0,
mlx_array* res_1,
const mlx_array a,
const mlx_stream s);
int mlx_linalg_solve(
mlx_array* res,
const mlx_array a,
const mlx_array b,
const mlx_stream s);
int mlx_linalg_solve_triangular(
mlx_array* res,
const mlx_array a,
const mlx_array b,
bool upper,
const mlx_stream s);
int mlx_linalg_svd(
mlx_vector_array* res,
const mlx_array a,
bool compute_uv,
const mlx_stream s);
int mlx_linalg_tri_inv(
mlx_array* res,
const mlx_array a,
bool upper,
const mlx_stream s);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,149 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_MAP_H
#define MLX_MAP_H
#include "mlx/c/array.h"
#include "mlx/c/string.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_map Maps
* MLX map objects.
*/
/**@{*/
/**
* A string-to-array map
*/
typedef struct mlx_map_string_to_array_ {
void* ctx;
} mlx_map_string_to_array;
/**
* Returns a new empty string-to-array map.
*/
mlx_map_string_to_array mlx_map_string_to_array_new(void);
/**
* Set map to provided src map.
*/
int mlx_map_string_to_array_set(
mlx_map_string_to_array* map,
const mlx_map_string_to_array src);
/**
* Free a string-to-array map.
*/
int mlx_map_string_to_array_free(mlx_map_string_to_array map);
/**
* Insert a new `value` at the specified `key` in the map.
*/
int mlx_map_string_to_array_insert(
mlx_map_string_to_array map,
const char* key,
const mlx_array value);
/**
* Returns the value indexed at the specified `key` in the map.
*/
int mlx_map_string_to_array_get(
mlx_array* value,
const mlx_map_string_to_array map,
const char* key);
/**
* An iterator over a string-to-array map.
*/
typedef struct mlx_map_string_to_array_iterator_ {
void* ctx;
void* map_ctx;
} mlx_map_string_to_array_iterator;
/**
* Returns a new iterator over the given map.
*/
mlx_map_string_to_array_iterator mlx_map_string_to_array_iterator_new(
mlx_map_string_to_array map);
/**
* Free iterator.
*/
int mlx_map_string_to_array_iterator_free(mlx_map_string_to_array_iterator it);
/**
* Increment iterator.
*/
int mlx_map_string_to_array_iterator_next(
const char** key,
mlx_array* value,
mlx_map_string_to_array_iterator it);
/**
* A string-to-string map
*/
typedef struct mlx_map_string_to_string_ {
void* ctx;
} mlx_map_string_to_string;
/**
* Returns a new empty string-to-string map.
*/
mlx_map_string_to_string mlx_map_string_to_string_new(void);
/**
* Set map to provided src map.
*/
int mlx_map_string_to_string_set(
mlx_map_string_to_string* map,
const mlx_map_string_to_string src);
/**
* Free a string-to-string map.
*/
int mlx_map_string_to_string_free(mlx_map_string_to_string map);
/**
* Insert a new `value` at the specified `key` in the map.
*/
int mlx_map_string_to_string_insert(
mlx_map_string_to_string map,
const char* key,
const char* value);
/**
* Returns the value indexed at the specified `key` in the map.
*/
int mlx_map_string_to_string_get(
const char** value,
const mlx_map_string_to_string map,
const char* key);
/**
* An iterator over a string-to-string map.
*/
typedef struct mlx_map_string_to_string_iterator_ {
void* ctx;
void* map_ctx;
} mlx_map_string_to_string_iterator;
/**
* Returns a new iterator over the given map.
*/
mlx_map_string_to_string_iterator mlx_map_string_to_string_iterator_new(
mlx_map_string_to_string map);
/**
* Free iterator.
*/
int mlx_map_string_to_string_iterator_free(
mlx_map_string_to_string_iterator it);
/**
* Increment iterator.
*/
int mlx_map_string_to_string_iterator_next(
const char** key,
const char** value,
mlx_map_string_to_string_iterator it);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,47 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_MEMORY_H
#define MLX_MEMORY_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup memory Memory operations
*/
/**@{*/
int mlx_clear_cache(void);
int mlx_get_active_memory(size_t* res);
int mlx_get_cache_memory(size_t* res);
int mlx_get_memory_limit(size_t* res);
int mlx_get_peak_memory(size_t* res);
int mlx_reset_peak_memory(void);
int mlx_set_cache_limit(size_t* res, size_t limit);
int mlx_set_memory_limit(size_t* res, size_t limit);
int mlx_set_wired_limit(size_t* res, size_t limit);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,41 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_METAL_H
#define MLX_METAL_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup metal Metal specific operations
*/
/**@{*/
int mlx_metal_is_available(bool* res);
int mlx_metal_start_capture(const char* path);
int mlx_metal_stop_capture(void);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,35 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_ALL_H
#define MLX_ALL_H
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/compile.h"
#include "mlx/c/cuda.h"
#include "mlx/c/device.h"
#include "mlx/c/distributed.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/error.h"
#include "mlx/c/export.h"
#include "mlx/c/fast.h"
#include "mlx/c/fft.h"
#include "mlx/c/graph_utils.h"
#include "mlx/c/half.h"
#include "mlx/c/io.h"
#include "mlx/c/io_types.h"
#include "mlx/c/linalg.h"
#include "mlx/c/map.h"
#include "mlx/c/memory.h"
#include "mlx/c/metal.h"
#include "mlx/c/ops.h"
#include "mlx/c/optional.h"
#include "mlx/c/random.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/transforms.h"
#include "mlx/c/transforms_impl.h"
#include "mlx/c/vector.h"
#include "mlx/c/version.h"
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_OPTIONAL_H
#define MLX_OPTIONAL_H
#include <stdbool.h>
#include "mlx/c/array.h"
#include "mlx/c/string.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_optional Optionals
* MLX optional scalars.
*/
/**@{*/
/**
* A int optional.
*/
typedef struct mlx_optional_int_ {
int value;
bool has_value;
} mlx_optional_int;
/**
* A float optional.
*/
typedef struct mlx_optional_float_ {
float value;
bool has_value;
} mlx_optional_float;
/**
* A dtype optional.
*/
typedef struct mlx_optional_dtype_ {
mlx_dtype value;
bool has_value;
} mlx_optional_dtype;
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,166 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_RANDOM_H
#define MLX_RANDOM_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup random Random number operations
*/
/**@{*/
int mlx_random_bernoulli(
mlx_array* res,
const mlx_array p,
const int* shape,
size_t shape_num,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_bits(
mlx_array* res,
const int* shape,
size_t shape_num,
int width,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_categorical_shape(
mlx_array* res,
const mlx_array logits,
int axis,
const int* shape,
size_t shape_num,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_categorical_num_samples(
mlx_array* res,
const mlx_array logits_,
int axis,
int num_samples,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_categorical(
mlx_array* res,
const mlx_array logits,
int axis,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_gumbel(
mlx_array* res,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_key(mlx_array* res, uint64_t seed);
int mlx_random_laplace(
mlx_array* res,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
float loc,
float scale,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_multivariate_normal(
mlx_array* res,
const mlx_array mean,
const mlx_array cov,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_normal_broadcast(
mlx_array* res,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
const mlx_array loc /* may be null */,
const mlx_array scale /* may be null */,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_normal(
mlx_array* res,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
float loc,
float scale,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_permutation(
mlx_array* res,
const mlx_array x,
int axis,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_permutation_arange(
mlx_array* res,
int x,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_randint(
mlx_array* res,
const mlx_array low,
const mlx_array high,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_seed(uint64_t seed);
int mlx_random_split_num(
mlx_array* res,
const mlx_array key,
int num,
const mlx_stream s);
int mlx_random_split(
mlx_array* res_0,
mlx_array* res_1,
const mlx_array key,
const mlx_stream s);
int mlx_random_truncated_normal(
mlx_array* res,
const mlx_array lower,
const mlx_array upper,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
const mlx_array key /* may be null */,
const mlx_stream s);
int mlx_random_uniform(
mlx_array* res,
const mlx_array low,
const mlx_array high,
const int* shape,
size_t shape_num,
mlx_dtype dtype,
const mlx_array key /* may be null */,
const mlx_stream s);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,88 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_STREAM_H
#define MLX_STREAM_H
#include <stdbool.h>
#include "mlx/c/device.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_stream Stream
* MLX stream object.
*/
/**@{*/
/**
* A MLX stream object.
*/
typedef struct mlx_stream_ {
void* ctx;
} mlx_stream;
/**
* Returns a new empty stream.
*/
mlx_stream mlx_stream_new(void);
/**
* Returns a new stream on a device.
*/
mlx_stream mlx_stream_new_device(mlx_device dev);
/**
* Set stream to provided src stream.
*/
int mlx_stream_set(mlx_stream* stream, const mlx_stream src);
/**
* Free a stream.
*/
int mlx_stream_free(mlx_stream stream);
/**
* Get stream description.
*/
int mlx_stream_tostring(mlx_string* str, mlx_stream stream);
/**
* Check if streams are the same.
*/
bool mlx_stream_equal(mlx_stream lhs, mlx_stream rhs);
/**
* Return the device of the stream.
*/
int mlx_stream_get_device(mlx_device* dev, mlx_stream stream);
/**
* Return the index of the stream.
*/
int mlx_stream_get_index(int* index, mlx_stream stream);
/**
* Synchronize with the provided stream.
*/
int mlx_synchronize(mlx_stream stream);
/**
* Returns the default stream on the given device.
*/
int mlx_get_default_stream(mlx_stream* stream, mlx_device dev);
/**
* Set default stream.
*/
int mlx_set_default_stream(mlx_stream stream);
/**
* Returns the current default CPU stream.
*/
mlx_stream mlx_default_cpu_stream_new(void);
/**
* Returns the current default GPU stream.
*/
mlx_stream mlx_default_gpu_stream_new(void);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,55 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_STRING_H
#define MLX_STRING_H
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_string String
* MLX string object.
*/
/**@{*/
/**
* A MLX string object.
*/
typedef struct mlx_string_ {
void* ctx;
} mlx_string;
/**
* Returns a new empty string.
*/
mlx_string mlx_string_new(void);
/**
* Returns a new string, copying contents from `str`, which must end with `\0`.
*/
mlx_string mlx_string_new_data(const char* str);
/**
* Set string to src string.
*/
int mlx_string_set(mlx_string* str, const mlx_string src);
/**
* Returns a pointer to the string contents.
* The pointer is valid for the life duration of the string.
*/
const char* mlx_string_data(mlx_string str);
/**
* Free string.
*/
int mlx_string_free(mlx_string str);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,68 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_TRANSFORMS_H
#define MLX_TRANSFORMS_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup transforms Transform operations
*/
/**@{*/
int mlx_async_eval(const mlx_vector_array outputs);
int mlx_checkpoint(mlx_closure* res, const mlx_closure fun);
int mlx_custom_function(
mlx_closure* res,
const mlx_closure fun,
const mlx_closure_custom fun_vjp /* may be null */,
const mlx_closure_custom_jvp fun_jvp /* may be null */,
const mlx_closure_custom_vmap fun_vmap /* may be null */);
int mlx_custom_vjp(
mlx_closure* res,
const mlx_closure fun,
const mlx_closure_custom fun_vjp);
int mlx_eval(const mlx_vector_array outputs);
int mlx_jvp(
mlx_vector_array* res_0,
mlx_vector_array* res_1,
const mlx_closure fun,
const mlx_vector_array primals,
const mlx_vector_array tangents);
int mlx_value_and_grad(
mlx_closure_value_and_grad* res,
const mlx_closure fun,
const int* argnums,
size_t argnums_num);
int mlx_vjp(
mlx_vector_array* res_0,
mlx_vector_array* res_1,
const mlx_closure fun,
const mlx_vector_array primals,
const mlx_vector_array cotangents);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,54 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_TRANSFORMS_IMPL_H
#define MLX_TRANSFORMS_IMPL_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "mlx/c/array.h"
#include "mlx/c/closure.h"
#include "mlx/c/distributed_group.h"
#include "mlx/c/io_types.h"
#include "mlx/c/map.h"
#include "mlx/c/stream.h"
#include "mlx/c/string.h"
#include "mlx/c/vector.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup transforms_impl Implementation detail operations
*/
/**@{*/
int mlx_detail_vmap_replace(
mlx_vector_array* res,
const mlx_vector_array inputs,
const mlx_vector_array s_inputs,
const mlx_vector_array s_outputs,
const int* in_axes,
size_t in_axes_num,
const int* out_axes,
size_t out_axes_num);
int mlx_detail_vmap_trace(
mlx_vector_array* res_0,
mlx_vector_array* res_1,
const mlx_closure fun,
const mlx_vector_array inputs,
const int* in_axes,
size_t in_axes_num);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,133 @@
/* Copyright © 2023-2024 Apple Inc. */
/* */
/* This file is auto-generated. Do not edit manually. */
/* */
#ifndef MLX_VECTOR_H
#define MLX_VECTOR_H
#include "mlx/c/array.h"
#include "mlx/c/string.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_vector Vectors
* MLX vector objects.
*/
/**@{*/
/**
* A vector of array.
*/
typedef struct mlx_vector_array_ {
void* ctx;
} mlx_vector_array;
mlx_vector_array mlx_vector_array_new(void);
int mlx_vector_array_set(mlx_vector_array* vec, const mlx_vector_array src);
int mlx_vector_array_free(mlx_vector_array vec);
mlx_vector_array mlx_vector_array_new_data(const mlx_array* data, size_t size);
mlx_vector_array mlx_vector_array_new_value(const mlx_array val);
int mlx_vector_array_set_data(
mlx_vector_array* vec,
const mlx_array* data,
size_t size);
int mlx_vector_array_set_value(mlx_vector_array* vec, const mlx_array val);
int mlx_vector_array_append_data(
mlx_vector_array vec,
const mlx_array* data,
size_t size);
int mlx_vector_array_append_value(mlx_vector_array vec, const mlx_array val);
size_t mlx_vector_array_size(mlx_vector_array vec);
int mlx_vector_array_get(
mlx_array* res,
const mlx_vector_array vec,
size_t idx);
/**
* A vector of vector_array.
*/
typedef struct mlx_vector_vector_array_ {
void* ctx;
} mlx_vector_vector_array;
mlx_vector_vector_array mlx_vector_vector_array_new(void);
int mlx_vector_vector_array_set(
mlx_vector_vector_array* vec,
const mlx_vector_vector_array src);
int mlx_vector_vector_array_free(mlx_vector_vector_array vec);
mlx_vector_vector_array mlx_vector_vector_array_new_data(
const mlx_vector_array* data,
size_t size);
mlx_vector_vector_array mlx_vector_vector_array_new_value(
const mlx_vector_array val);
int mlx_vector_vector_array_set_data(
mlx_vector_vector_array* vec,
const mlx_vector_array* data,
size_t size);
int mlx_vector_vector_array_set_value(
mlx_vector_vector_array* vec,
const mlx_vector_array val);
int mlx_vector_vector_array_append_data(
mlx_vector_vector_array vec,
const mlx_vector_array* data,
size_t size);
int mlx_vector_vector_array_append_value(
mlx_vector_vector_array vec,
const mlx_vector_array val);
size_t mlx_vector_vector_array_size(mlx_vector_vector_array vec);
int mlx_vector_vector_array_get(
mlx_vector_array* res,
const mlx_vector_vector_array vec,
size_t idx);
/**
* A vector of int.
*/
typedef struct mlx_vector_int_ {
void* ctx;
} mlx_vector_int;
mlx_vector_int mlx_vector_int_new(void);
int mlx_vector_int_set(mlx_vector_int* vec, const mlx_vector_int src);
int mlx_vector_int_free(mlx_vector_int vec);
mlx_vector_int mlx_vector_int_new_data(int* data, size_t size);
mlx_vector_int mlx_vector_int_new_value(int val);
int mlx_vector_int_set_data(mlx_vector_int* vec, int* data, size_t size);
int mlx_vector_int_set_value(mlx_vector_int* vec, int val);
int mlx_vector_int_append_data(mlx_vector_int vec, int* data, size_t size);
int mlx_vector_int_append_value(mlx_vector_int vec, int val);
size_t mlx_vector_int_size(mlx_vector_int vec);
int mlx_vector_int_get(int* res, const mlx_vector_int vec, size_t idx);
/**
* A vector of string.
*/
typedef struct mlx_vector_string_ {
void* ctx;
} mlx_vector_string;
mlx_vector_string mlx_vector_string_new(void);
int mlx_vector_string_set(mlx_vector_string* vec, const mlx_vector_string src);
int mlx_vector_string_free(mlx_vector_string vec);
mlx_vector_string mlx_vector_string_new_data(const char** data, size_t size);
mlx_vector_string mlx_vector_string_new_value(const char* val);
int mlx_vector_string_set_data(
mlx_vector_string* vec,
const char** data,
size_t size);
int mlx_vector_string_set_value(mlx_vector_string* vec, const char* val);
int mlx_vector_string_append_data(
mlx_vector_string vec,
const char** data,
size_t size);
int mlx_vector_string_append_value(mlx_vector_string vec, const char* val);
size_t mlx_vector_string_size(mlx_vector_string vec);
int mlx_vector_string_get(char** res, const mlx_vector_string vec, size_t idx);
/**@}*/
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,18 @@
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_VERSION_H
#define MLX_VERSION_H
#include "mlx/c/string.h"
#ifdef __cplusplus
extern "C" {
#endif
int mlx_version(mlx_string* str_);
#ifdef __cplusplus
}
#endif
#endif