For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /max/get-started.md).
Types
#include "max/c/types.h"Typedefs:
M_Statusβ
typedef struct M_Status M_Status
Contains the success or failure of an API call.
In general, any API that may fail accepts a M_Status argument that is filled in with a meaningful error message on failure.
You can create this with M_newStatus(). When youβre done, call M_freeStatus().
M_RuntimeConfigβ
typedef struct M_RuntimeConfig M_RuntimeConfig
Specifies the MAX Engine configuration.
Configuration properties include the number of threads, artifact path, etc.
You can create this with M_newRuntimeConfig(). When youβre done, call M_freeRuntimeConfig().
M_RuntimeContextβ
typedef struct M_RuntimeContext M_RuntimeContext
Contains information that needs to be shared between APIs.
You can create this with M_newRuntimeContext(). When youβre done, call M_freeRuntimeContext().
M_CompileConfigβ
typedef struct M_CompileConfig M_CompileConfig
Specifies the configuration required for model compilation.
You can create this with M_newCompileConfig(). When youβre done, call M_freeCompileConfig().
M_AsyncCompiledModelβ
typedef struct M_AsyncCompiledModel M_AsyncCompiledModel
Contains an async value to a compiled model.
M_AsyncCompiledModel can be passed to other APIs that accept compiled models as a function parameter. This async value will eventually resolve to a compiled model or an error in the case of compilation failure.
You can create this with M_compileModel(). When youβre done, call M_freeCompiledModel().
M_AsyncModelβ
typedef struct M_AsyncModel M_AsyncModel
Contains a future used for inference.
The future will resolve to a model thatβs ready for inference.
You can create this with M_initModel(). When youβre done, call M_freeModel().
M_AsyncTensorβ
typedef struct M_AsyncTensor M_AsyncTensor
Contains an async value to a tensor for inference.
You can get this from M_getTensorByNameFrom(). When youβre done, call M_freeTensor().
M_TensorNameArrayβ
typedef struct M_TensorNameArray M_TensorNameArray
Contains an array of tensor names of model inputs or outputs.
You can get this from M_getInputNames() and M_getOutputNames(). When youβre done, call M_freeTensorNameArray().
M_TensorSpecβ
typedef struct M_TensorSpec M_TensorSpec
Contains the representation of a shape and an element type.
You can create this with M_newTensorSpec(). When youβre done, call M_freeTensorSpec().
M_AsyncTensorMapβ
typedef struct M_AsyncTensorMap M_AsyncTensorMap
Contains a collection of tensors.
The collection of tensors is used to represent inputs and outputs when executing a model.
You can create this with M_newAsyncTensorMap(). When youβre done, call M_freeAsyncTensorMap().
M_WeightsRegistryβ
typedef struct M_WeightsRegistry M_WeightsRegistry
Maps unique weight names to their backing data.
You can create this with M_newWeightsRegistry(). When youβre done, call M_freeWeightsRegistry().
M_Safetensorsβ
typedef struct M_Safetensors M_Safetensors
Holds the tensors parsed from one or more safetensors files.
The tensor data is borrowed from the loaded files and stays valid for the lifetime of this object. You can enumerate tensors, read their data and metadata, or build a M_WeightsRegistry from all of them with M_newWeightsRegistryFromSafetensors().
You can create this with M_loadSafetensors(). When youβre done, call M_freeSafetensors().
M_Deviceβ
typedef struct M_Device M_Device
Contains a device handle.
A device represents a computational unit (CPU or GPU) that can execute operations and hold tensors.
You can create this with M_newDevice(). When youβre done, call M_freeDevice().
Enums:
M_Dtypeβ
enum M_Dtype
Represents all data types supported by the framework.
Values:
M_UNKNOWNβ
enumerator M_UNKNOWN
mIsIntegerβ
enumerator mIsInteger
mIsFloatβ
enumerator mIsFloat
mIsComplexβ
enumerator mIsComplex
mIsSignedβ
enumerator mIsSigned
Bit 0 encodes βisSignedβ.
kIntWidthShiftβ
enumerator kIntWidthShift
M_INT1β
enumerator M_INT1
M_UINT1β
enumerator M_UINT1
M_INT2β
enumerator M_INT2
M_UINT2β
enumerator M_UINT2
M_INT4β
enumerator M_INT4
M_UINT4β
enumerator M_UINT4
M_INT8β
enumerator M_INT8
M_UINT8β
enumerator M_UINT8
M_INT16β
enumerator M_INT16
M_UINT16β
enumerator M_UINT16
M_INT32β
enumerator M_INT32
M_UINT32β
enumerator M_UINT32
M_INT64β
enumerator M_INT64
M_UINT64β
enumerator M_UINT64
M_INT128β
enumerator M_INT128
M_UINT128β
enumerator M_UINT128
M_FLOAT4_E2M1FNβ
enumerator M_FLOAT4_E2M1FN
Bits 0 through 3 indicate the kind of FP value.
M_FLOAT8_E8M0FNUβ
enumerator M_FLOAT8_E8M0FNU
Some slots are left blank here to enable us to support more lower precision types in the future.
M_FLOAT8_E3M4β
enumerator M_FLOAT8_E3M4
M_FLOAT8_E4M3FNβ
enumerator M_FLOAT8_E4M3FN
M_FLOAT8_E4M3FNUZβ
enumerator M_FLOAT8_E4M3FNUZ
M_FLOAT8_E5M2β
enumerator M_FLOAT8_E5M2
M_FLOAT8_E5M2FNUZβ
enumerator M_FLOAT8_E5M2FNUZ
M_FLOAT16β
enumerator M_FLOAT16
M_BFLOAT16β
enumerator M_BFLOAT16
M_FLOAT32β
enumerator M_FLOAT32
M_FLOAT64β
enumerator M_FLOAT64
M_BOOLβ
enumerator M_BOOL
M_AllocatorTypeβ
enum M_AllocatorType
Contains an AllocatorType. You can choose between kCaching and kSystem kCaching trades off higher memory usage for better performance. kSystem uses the default system allocator.
Values:
kSystemβ
enumerator kSystem
kCachingβ
enumerator kCaching
M_ValueTypeβ
enum M_ValueType
Represents the type of a value.
Values:
M_STRING_VALUEβ
enumerator M_STRING_VALUE
M_DOUBLE_VALUEβ
enumerator M_DOUBLE_VALUE
M_LONG_VALUEβ
enumerator M_LONG_VALUE
M_BOOL_VALUEβ
enumerator M_BOOL_VALUE
M_TENSOR_VALUEβ
enumerator M_TENSOR_VALUE
M_LIST_VALUEβ
enumerator M_LIST_VALUE
M_TUPLE_VALUEβ
enumerator M_TUPLE_VALUE
M_DICT_VALUEβ
enumerator M_DICT_VALUE
M_NONE_VALUEβ
enumerator M_NONE_VALUE
M_UNKNOWN_VALUEβ
enumerator M_UNKNOWN_VALUE
M_MOJO_VALUEβ
enumerator M_MOJO_VALUE
M_PYTHON_MOJO_VALUEβ
enumerator M_PYTHON_MOJO_VALUE
M_DeviceTypeβ
enum M_DeviceType
Represents the type of device. M_HOST is the CPU; M_ACCELERATOR is any non-CPU compute device (GPU or NPU). The closed set of valid device labels is enforced by EngineContext::create β see Support/DeviceSpecs.h for the label constants and max/internal/lib/API/c/EngineContext.cpp for the validating guard.
Values:
M_HOSTβ
enumerator M_HOST
M_ACCELERATORβ
enumerator M_ACCELERATOR
M_ResultOutputStyleβ
enum M_ResultOutputStyle
Represents the result output style for debug printing.
Values:
M_COMPACTβ
enumerator M_COMPACT
M_FULLβ
enumerator M_FULL
M_BINARYβ
enumerator M_BINARY
M_BINARY_MAX_CHECKPOINTβ
enumerator M_BINARY_MAX_CHECKPOINT
M_NONEβ
enumerator M_NONE
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!