IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /max/get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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_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