1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//===----------------------------------------------------------------------===//
// Copyright (c) 2026, Modular Inc. All rights reserved.
//
// Licensed under the Apache License v2.0 with LLVM Exceptions:
// https://llvm.org/LICENSE.txt
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//
/// Creates a new runtime config.
///
/// This configures runtime details such as the number of threads and log level.
///
/// By default, the config object's number of threads will be set to `0`, which
/// is internally used to refer to the number of physical processors in the
/// first socket in the system. You can change this with `M_setNumThreads()`.
///
/// You need this as an argument for `M_newRuntimeContext()`.
///
/// @returns A pointer to the new runtime config. You are responsible for
/// the memory associated with the pointer returned. You can deallocate the
/// memory by calling `M_freeRuntimeConfig()`.
MODULAR_API_EXPORT M_RuntimeConfig *;
/// Deallocates the memory for a runtime config. No-op if `config` is `NULL`.
///
/// @param config The runtime config.
MODULAR_API_EXPORT void ;
/// Adds a device to be accessible from the runtime.
///
/// @param config The runtime config.
/// @param device The device to add to the runtime config.
MODULAR_API_EXPORT void ;
/// Creates a runtime context.
///
/// The context is an application-level object that sets up various resources
/// such as threadpool and allocators during inference. You need this
/// before you can call `M_compileModel()`.
///
/// It's expected that there's only one runtime context active in an
/// inference session at a time. We recommended you create
/// one context and use it throughout your application.
///
/// For example:
///
/// ```c
/// M_Status *status = M_newStatus();
/// M_RuntimeConfig *runtimeConfig = M_newRuntimeConfig();
/// M_RuntimeContext *context = M_newRuntimeContext(runtimeConfig, status);
/// if (M_isError(status)) {
/// logError(M_getError(status));
/// return EXIT_FAILURE;
/// }
/// ```
///
/// @param config The runtime config, from `M_newRuntimeConfig()`.
/// @param status The status object for reporting errors. It is filled with
/// an error message if construction of the runtime context fails.
///
/// @returns A pointer to the runtime context object. On success, this is a
/// valid pointer. On failure, this is a `NULL` pointer with an error message
/// in the status. You are responsible for the memory associated with the
/// pointer returned. You can deallocate the memory by calling
/// `M_freeRuntimeContext()`.
MODULAR_API_EXPORT M_RuntimeContext *
;
/// Deallocates the memory for a runtime context. No-op if `context` is `NULL`.
///
/// @param context The runtime context.
MODULAR_API_EXPORT void ;
/// Set the options for debugging printing of tensors when executing a model.
///
/// @param context The runtime context.
/// @param style The way the data will be printed.
/// @param precision The floating point print out precision.
/// @param directory The directory to store binary output.
MODULAR_API_EXPORT void ;
/// Sets a mojo compile-time define with an boolean value.
///
/// @param context The runtime context.
/// @param key The name of the define.
/// @param value The boolean to set the define to.
MODULAR_API_EXPORT void ;
/// Sets a mojo compile-time define with an integer value.
///
/// @param context The runtime context.
/// @param key The name of the define.
/// @param value The integer to set the define to.
MODULAR_API_EXPORT void ;
/// Sets a mojo compile-time define with an string value.
///
/// @param context The runtime context.
/// @param key The name of the define.
/// @param value The string to set the define to.
MODULAR_API_EXPORT void ;
// MAX_C_CONTEXT_H