Skip to main content

Crate max_sys

Crate max_sys 

Source
Expand description

Raw FFI bindings to the Modular MAX C API.

Generated by bindgen from the headers in max/include/max/c/. These are opaque-struct-based bindings — you interact through function pointers, not by reading struct fields directly.

For a safe, ergonomic API, use pyroxide instead.

Structs§

M_AsyncCompiledModel
M_AsyncModel
M_AsyncTensor
M_AsyncTensorMap
M_CompileConfig
M_Device
M_RuntimeConfig
M_RuntimeContext
M_Status
M_TensorNameArray
M_TensorSpec
M_WeightsRegistry

Constants§

M_AllocatorType_kCaching
M_AllocatorType_kSystem
M_DeviceType_M_ACCELERATOR
M_DeviceType_M_HOST
M_Dtype_M_BFLOAT16
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_BOOL
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT4_E2M1FN
Bits 0 through 3 indicate the kind of FP value.
M_Dtype_M_FLOAT8_E3M4
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT8_E4M3FN
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT8_E4M3FNUZ
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT8_E5M2
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT8_E5M2FNUZ
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT8_E8M0FNU
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT16
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT32
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_FLOAT64
Some slots are left blank here to enable us to support more lower precision types in the future.
M_Dtype_M_INT1
Bit 0 encodes “isSigned”.
M_Dtype_M_INT2
Bit 0 encodes “isSigned”.
M_Dtype_M_INT4
Bit 0 encodes “isSigned”.
M_Dtype_M_INT8
Bit 0 encodes “isSigned”.
M_Dtype_M_INT16
Bit 0 encodes “isSigned”.
M_Dtype_M_INT32
Bit 0 encodes “isSigned”.
M_Dtype_M_INT64
Bit 0 encodes “isSigned”.
M_Dtype_M_INT128
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT1
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT2
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT4
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT8
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT16
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT32
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT64
Bit 0 encodes “isSigned”.
M_Dtype_M_UINT128
Bit 0 encodes “isSigned”.
M_Dtype_M_UNKNOWN
M_Dtype_kIntWidthShift
Bit 0 encodes “isSigned”.
M_Dtype_mIsComplex
M_Dtype_mIsFloat
M_Dtype_mIsInteger
M_Dtype_mIsSigned
Bit 0 encodes “isSigned”.
M_ResultOutputStyle_M_BINARY
M_ResultOutputStyle_M_BINARY_MAX_CHECKPOINT
M_ResultOutputStyle_M_COMPACT
M_ResultOutputStyle_M_FULL
M_ResultOutputStyle_M_NONE
M_ValueType_M_BOOL_VALUE
M_ValueType_M_DICT_VALUE
M_ValueType_M_DOUBLE_VALUE
M_ValueType_M_LIST_VALUE
M_ValueType_M_LONG_VALUE
M_ValueType_M_MOJO_VALUE
M_ValueType_M_NONE_VALUE
M_ValueType_M_PYTHON_MOJO_VALUE
M_ValueType_M_STRING_VALUE
M_ValueType_M_TENSOR_VALUE
M_ValueType_M_TUPLE_VALUE
M_ValueType_M_UNKNOWN_VALUE

Functions§

M_borrowTensorInto
Adds a tensor to the tensor map.
M_captureModelSync
Captures model execution into a device graph for later replay.
M_compileModel
Compiles a model.
M_compileModelSync
Synchronously compiles a model.
M_copyTensorToDevice
Copies a tensor to a different device.
M_debugVerifyReplayModelSync
Executes eagerly and verifies that the kernel launch trace matches a previously captured device graph.
M_executeModelSync
Executes a model synchronously.
M_freeAsyncTensorMap
Deallocates the memory for the tensor map. No-op if tensorMap is NULL.
M_freeCompileConfig
Deallocates the memory for the compile config. No-op if config is NULL.
M_freeCompiledModel
Deallocates the memory for the compiled model. No-op if model is NULL.
M_freeDevice
Deallocates the memory for a device. No-op if device is NULL.
M_freeModel
Deallocates the memory for the model. No-op if model is NULL.
M_freeRuntimeConfig
Deallocates the memory for a runtime config. No-op if config is NULL.
M_freeRuntimeContext
Deallocates the memory for a runtime context. No-op if context is NULL.
M_freeStatus
Deallocates the memory for the status object. No-op if status is NULL.
M_freeTensor
Deallocates the memory for the tensor. No-op if tensor is NULL.
M_freeTensorNameArray
Deallocates the memory for the array of tensor names. No-op if names is NULL.
M_freeTensorSpec
Deallocates the memory for the tensor spec. No-op if spec is NULL.
M_freeWeightsRegistry
Deallocates the memory for the weights registry. No-op if weightsRegistry is NULL.
M_getAcceleratorCount
Returns the number of available accelerator (GPU) devices.
M_getDeviceId
Gets the ID of a device.
M_getDeviceIdFromSpec
Gets the device ID from a tensor specification.
M_getDeviceLabel
Gets the label of a device (e.g., “cpu” or “gpu”).
M_getDeviceType
Gets the type of a device.
M_getDeviceTypeFromSpec
Gets the device type from a tensor specification.
M_getDimAt
Gets the element at a particular axis.
M_getDtype
Gets the datatype from the tensor spec.
M_getError
Gets an error message from the M_Status parameter.
M_getName
Gets the name of the tensor from the tensor spec.
M_getRank
Gets the rank from the tensor spec.
M_getTensorByNameFrom
Gets a tensor from the tensor map by name.
M_getTensorData
Gets a pointer to underlying data of the tensor.
M_getTensorDevice
Gets the device on which a tensor resides.
M_getTensorNumElements
Gets the number of elements for the tensor.
M_getTensorSpec
Gets a Tensor Spec for the tensor.
M_getTensorType
Gets the corresponding M_Dtype for the tensor.
M_initModel
Sets up a model for execution.
M_isDynamicRanked
Returns if the given spec has a dynamic rank.
M_isError
Checks if status holds an error value.
M_isHostDevice
Checks if the device is a host device.
M_newAsyncTensorMap
Creates a map of tensor names to async tensors.
M_newCompileConfig
Creates an object you can use to configure model compilation.
M_newDevice
Creates a device of the specified type and ID.
M_newRuntimeConfig
Creates a new runtime config.
M_newRuntimeContext
Creates a runtime context.
M_newStatus
Creates a new status object.
M_newTensorSpec
Creates a tensor specification.
M_newWeightsRegistry
Creates a weights registry from parallel arrays of weight names and data pointers.
M_replayModelSync
Replays a previously captured device graph.
M_runtimeConfigAddDevice
Adds a device to be accessible from the runtime.
M_setDebugPrintOptions
Set the options for debugging printing of tensors when executing a model.
M_setModelPath
Sets the path to a model.
M_setMojoDefineBool
Sets a mojo compile-time define with an boolean value.
M_setMojoDefineInt
Sets a mojo compile-time define with an integer value.
M_setMojoDefineString
Sets a mojo compile-time define with an string value.
M_synchronizeDevice
Synchronizes the device, ensuring all operations complete.
M_version
Gets the MAX Engine version.
M_waitForCompilation
Blocks execution until the model is compiled.
M_waitForModel
Blocks execution until the model is initialized.

Type Aliases§

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.
M_DeviceType
M_Dtype
M_ResultOutputStyle
Represents the result output style for debug printing.
M_ValueType
Represents the type of a value.