Repository navigation
Expand file tree
/
Copy pathengine.pyi
More file actions
761 lines (610 loc) · 26.6 KB
/
Copy pathengine.pyi
File metadata and controls
761 lines (610 loc) · 26.6 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
# ===----------------------------------------------------------------------=== #
# 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.
# ===----------------------------------------------------------------------=== #
# GENERATED FILE, DO NOT EDIT MANUALLY!
# ===----------------------------------------------------------------------=== #
"""Modular framework Python bindings."""
import enum
import inspect
import os
import pathlib
import types
from collections.abc import Iterator, Mapping, Sequence
from typing import Any, TypeAlias, overload
import max._core.driver
import max._core.dtype
import max._core.mlrt
from max._core.driver import Buffer
from max._core.mlrt import AsyncValue
from max._core_types.driver import DLPackArray
InputType: TypeAlias = DLPackArray | Buffer | int | float | bool
class ModelExecutionError(RuntimeError, ValueError):
"""
Raised when ``Model.execute`` fails, often in one of the model's kernels. The message names the kernel and, with ``source_tracebacks``, the lines of your model it runs. It is a ``RuntimeError``, and a ``ValueError`` for code written before it.
"""
class TensorSpec:
"""
Defines the properties of a tensor, including its name, shape and data type.
For usage examples, see :obj:`Model.input_metadata`.
"""
@property
def dtype(self) -> max._core.dtype.DType:
"""A tensor data type."""
@property
def name(self) -> str:
"""A tensor name."""
@property
def shape(self) -> list[int | None] | None:
"""
The shape of the tensor as a list of integers.
If a dimension size is unknown/dynamic (such as the batch size), its
value is ``None``.
"""
class ModelMetadata:
"""Input and output metadata for a compiled model function."""
@property
def name(self) -> str: ...
@property
def input_metadata(self) -> list[TensorSpec]: ...
@property
def output_metadata(self) -> list[TensorSpec]: ...
class CompiledModels:
"""A compiled model artifact containing one or more submodels."""
def __len__(self) -> int: ...
def __getitem__(self, arg: int, /) -> ModelMetadata: ...
def __iter__(self) -> Iterator[ModelMetadata]: ...
@property
def names(self) -> list[str]: ...
def export_mef(self, path: str) -> None:
"""
Exports the compiled model as MEF bytes to the given file.
Args:
path: The filesystem path to write the MEF to.
"""
def get_config_value(key: str) -> str:
"""
Reads a config value.
Global overrides take priority, then the ``MODULAR_<KEY>``
environment variable, then ``modular.cfg``.
Raises:
KeyError: If the key is not set in any source.
RuntimeError: If the config fails to open.
"""
def get_global_value(key: str) -> str | None:
"""
Returns the process-wide override for ``key``, or ``None`` if unset.
Ignores environment variables and ``modular.cfg``.
"""
def set_global_value(key: str, value: str) -> None:
"""
Sets a process-wide config override.
Overrides take priority over environment variables and
``modular.cfg`` for every consumer in the process. They are not
inherited by subprocesses.
"""
def unset_global_value(key: str) -> None:
"""Removes an override set by :func:`set_global_value`."""
def max_cache_dir() -> pathlib.Path | None:
"""
Returns the directory the engine caches compiled models (``.mef``) in.
Resolved by the compiler itself.
Returns:
pathlib.Path | None: the cache directory, or None if unresolvable.
"""
@overload
def read(path: str | os.PathLike) -> CompiledModels:
"""
Reads a compiled-model artifact (``.mef``) from a file path.
Returns:
The artifact, ready to be initialized on any session via
``InferenceSession._load_all``.
Raises:
RuntimeError: If the file is missing or is not a valid MEF
for this engine build.
"""
@overload
def read(data: bytes) -> CompiledModels:
"""
Reads a compiled-model artifact (``.mef``) from bytes.
Returns:
The artifact, ready to be initialized on any session via
``InferenceSession._load_all``.
Raises:
RuntimeError: If the bytes are not a valid MEF for this
engine build.
"""
class Model:
"""
A loaded model that you can execute.
Do not instantiate this class directly. Instead, create it with
:meth:`InferenceSession.load` or :meth:`InferenceSession.init`.
A :class:`Model` is callable. Calling it directly (``model(inputs...)``)
accepts tensors as positional or keyword arguments and dispatches
to :meth:`execute`. You can also call :meth:`execute` directly, which
accepts positional arguments only.
When using keyword arguments, the names must match the model's input
metadata (see :attr:`input_metadata`). Calling the model raises
``TypeError`` if a keyword argument doesn't match a model input, if a
positional and keyword argument refer to the same parameter, or if the
number of inputs doesn't match.
For supported input types and execution errors, see :meth:`execute`.
For example, load a graph, list its inputs, and run it:
.. code-block:: python
import numpy as np
from max.driver import CPU
from max.dtype import DType
from max.engine import InferenceSession
from max.graph import DeviceRef, Graph, TensorType
with Graph(
"add_one",
input_types=[
TensorType(DType.float32, ["batch"], device=DeviceRef.CPU())
],
) as graph:
(x,) = graph.inputs
graph.output(x + 1.0)
session = InferenceSession(devices=[CPU()])
model = session.load(graph)
for tensor in model.input_metadata:
print(
f"name: {tensor.name}, shape: {tensor.shape},"
f" dtype: {tensor.dtype}"
)
outputs = model.execute(np.ones((2,), np.float32))
"""
@property
def devices(self) -> list[max._core.driver.Device]:
"""The device objects used by the model."""
@property
def input_devices(self) -> list[max._core.driver.Device]:
"""
The devices of the model's input tensors, as a list of :class:`Device` objects.
"""
@property
def input_metadata(self) -> list[TensorSpec]:
"""
Metadata about the model's input tensors, as a list of :class:`TensorSpec` objects.
For example, you can print the input tensor names, shapes, and dtypes:
.. code-block:: python
from max.driver import CPU
from max.dtype import DType
from max.engine import InferenceSession
from max.graph import DeviceRef, Graph, TensorType
device = CPU()
device_ref = DeviceRef.from_device(device)
input_type = TensorType(DType.float32, [2, 3], device=device_ref)
with Graph("metadata", input_types=[input_type]) as graph:
graph.output(graph.inputs[0])
session = InferenceSession(devices=[device])
model = session.load(graph)
for tensor in model.input_metadata:
print(f'name: {tensor.name}, shape: {tensor.shape}, dtype: {tensor.dtype}')
"""
@property
def output_devices(self) -> list[max._core.driver.Device]:
"""
The devices of the model's output tensors, as a list of :class:`Device` objects.
"""
@property
def output_metadata(self) -> list[TensorSpec]:
"""
Metadata about the model's output tensors, as a list of :class:`TensorSpec` objects.
For example, you can print the output tensor names, shapes, and dtypes:
.. code-block:: python
from max.driver import CPU
from max.dtype import DType
from max.engine import InferenceSession
from max.graph import DeviceRef, Graph, TensorType
device = CPU()
device_ref = DeviceRef.from_device(device)
input_type = TensorType(DType.float32, [2, 3], device=device_ref)
with Graph("metadata", input_types=[input_type]) as graph:
graph.output(graph.inputs[0])
session = InferenceSession(devices=[device])
model = session.load(graph)
for tensor in model.output_metadata:
print(f'name: {tensor.name}, shape: {tensor.shape}, dtype: {tensor.dtype}')
"""
@property
def kernel_summaries(self) -> list[str]:
"""
Kernel fusion summaries from the compiled model.
Returns a list of strings, one per ``mgp.generic.execute`` kernel in
the compiled graph. Each string describes the fused kernel
composition, such as
``"Epilogue(custom__kv_rope, custom__kv_cache_store)"``.
"""
@property
def name(self) -> str:
"""
The symbol name of this model.
Mirrors the ``sym_name`` of the model's ``mo.graph`` op, preserved
through MEF serialization. Used by
:meth:`InferenceSession.load_all` to key the returned dict by graph
name.
"""
@property
def signature(self) -> inspect.Signature:
"""The input signature for the model."""
def execute(self, *args: InputType) -> list[Buffer]:
"""
Executes the model with the provided input and returns the outputs.
For example, compiling a small graph and executing it:
.. code-block:: python
from max.driver import CPU
from max.dtype import DType
from max.engine import InferenceSession
from max.graph import DeviceRef, Graph, ops
device = CPU()
device_ref = DeviceRef.from_device(device)
with Graph("add") as graph:
graph.output(
ops.add(
ops.constant([1.0, 2.0], DType.float32, device=device_ref),
ops.constant([3.0, 4.0], DType.float32, device=device_ref),
)
)
session = InferenceSession(devices=[device])
model = session.load(graph)
result = model.execute()[0]
.. invisible-code-block: python
import numpy as np
np.testing.assert_allclose(result.to_numpy(), [4.0, 6.0])
Args:
args: A list of input tensors. The following input types are
supported:
* Any tensors implementing the DLPack protocol, such as
:obj:`np.ndarray` or :obj:`torch.Tensor`.
* MAX driver buffers, such as :obj:`max.driver.Buffer`.
* Scalar inputs, such as :obj:`bool`, :obj:`float`, :obj:`int`,
or :obj:`np.generic`.
All inputs are copied to the device that the model is resident on
prior to executing.
Returns:
A list of output tensors. The output tensors are resident on the
execution device.
Raises:
RuntimeError: If the given input tensors' shapes don't match what
the model expects.
TypeError: If the given input tensors' dtype can't be cast to what
the model expects.
ValueError: If positional inputs aren't one of the supported
types.
"""
def __call__(self, *args: InputType, **kwargs: InputType) -> list[Buffer]:
"""Executes the model. See :class:`Model` for details."""
def capture(
self, graph_keys: int | Sequence[int], *inputs: Buffer
) -> list[Buffer]:
"""
Captures execution into a device graph for the caller-provided key.
Capture is best-effort and model-dependent. It records the current
execution path; models that perform unsupported operations during
capture (for example, host-device synchronization) fail to capture.
Callers should decide which phases are safe to capture (such as
decode-only phases in serving).
"""
def replay(self, graph_keys: int | Sequence[int], *inputs: Buffer) -> None:
"""Replays the captured device graph for the provided key."""
def debug_verify_replay(
self, graph_keys: int | Sequence[int], *inputs: Buffer
) -> None:
"""
Executes eagerly and verifies the launch trace matches the captured graph.
This method validates that graph capture correctly represents eager
execution by running the model and comparing kernel launch traces.
Useful for debugging graph capture issues.
Args:
graph_keys: One graph key per participating device stream.
inputs: The input buffers matching the captured input signature.
Raises:
RuntimeError: If no graph was captured or trace verification
fails.
"""
def release_captured_graph(self, graph_keys: int | Sequence[int]) -> None:
"""
Releases a previously captured device graph.
Drops the device-side graph and its working memory once the last
reference held by the runtime is released. Releasing a key that was
never captured is a no-op.
Args:
graph_keys: The caller-provided graph key (or per-device keys)
identifying the captured graph to release.
"""
def _execute_device_tensors(
self, tensors: Sequence[max._core.driver.Buffer]
) -> list[max._core.driver.Buffer]: ...
def _capture(
self,
graph_keys: Sequence[int],
inputs: Sequence[max._core.driver.Buffer],
) -> list[max._core.driver.Buffer]:
"""Capture execution into a device graph."""
def _replay(
self,
graph_keys: Sequence[int],
inputs: Sequence[max._core.driver.Buffer],
) -> None:
"""Replay the captured device graph."""
def _debug_verify_replay(
self,
graph_keys: Sequence[int],
inputs: Sequence[max._core.driver.Buffer],
) -> None:
"""Debug verify replay against captured graph."""
def _await_device_graphs(self) -> None:
"""Await all pending device graph instantiations."""
def _release_captured_graph(self, graph_keys: Sequence[int]) -> None:
"""Release captured device graphs for the given keys."""
def _export_mef(self, path: str) -> None:
"""
Exports the compiled model as a mef to a file.
Args:
path: The filename where the mef is exported to.
"""
def reload(self, weights_registry: Mapping[str, Any]) -> None: ...
def release_weights(self) -> None:
"""
Drops the host-side weight references held by this model.
Releases the weights registry and the owning references, so the host
weight memory can be freed once the caller drops its own references.
Safe only when every weight was copied to its execution device during
model init: reading a host weight after this call is undefined
behavior. ``reload`` remains usable afterwards.
"""
class DebugConfig:
"""
Unified debug configuration for MAX inference.
``DebugConfig`` is a process-wide singleton accessed through
:attr:`InferenceSession.debug`. It controls model debugging features
such as ``NaN`` checks, synchronous GPU execution, stack traces, and IR
dumping.
There are two ways to configure debugging options:
* Set the ``MODULAR_DEBUG`` environment variable to a list of
kebab-case property names separated by commas. Boolean properties
can be enabled with just the name; others use ``name=value`` form.
For example: ``MODULAR_DEBUG=nan-check,assert-level=all``.
* Set properties directly with the Python API, for example
``InferenceSession.debug.<property> = <value>``. Options are
class-level on :class:`InferenceSession` because they affect
globally shared infrastructure.
For the environment variable and config file, the name ``sensible``
enables a curated default set defined in :attr:`sensible_mode`.
"""
@property
def nan_check(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to insert runtime checks after each compiled op that abort if any output contains ``NaN``. Takes effect at model build time.
"""
@nan_check.setter
def nan_check(self, arg: bool, /) -> None: ...
@property
def uninitialized_read_check(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to instrument buffer reads to detect reads of uninitialized memory. Takes effect at model build time.
"""
@uninitialized_read_check.setter
def uninitialized_read_check(self, arg: bool, /) -> None: ...
@property
def uninitialized_read_mode(self) -> str:
r"""
A string that sets what :attr:`uninitialized_read_check` does on a match. One of ``\'\'``, ``'abort'``, ``'report'``. ``\'\'`` (unset) behaves as ``'abort'``, which stops at the first match. ``'report'`` prints each match and keeps running so a single run enumerates every offending load, with no bound on its output. On Apple GPUs, ``'report'`` currently aborts at the first match without printing. Ignored unless :attr:`uninitialized_read_check` is set. Takes effect at model build time.
"""
@uninitialized_read_mode.setter
def uninitialized_read_mode(self, arg: str, /) -> None: ...
@property
def device_sync_mode(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to force synchronous GPU execution so every device operation waits for completion. This surfaces async errors at their call site but serializes the pipeline. Takes effect at run time.
"""
@device_sync_mode.setter
def device_sync_mode(self, arg: bool, /) -> None: ...
@property
def stack_trace_on_error(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to print a C++ stack trace whenever a runtime error is raised. Takes effect at run time.
"""
@stack_trace_on_error.setter
def stack_trace_on_error(self, arg: bool, /) -> None: ...
@property
def stack_trace_on_crash(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to print a C++ stack trace on fatal signals such as ``SIGSEGV`` or ``SIGABRT``. Takes effect at run time.
"""
@stack_trace_on_crash.setter
def stack_trace_on_crash(self, arg: bool, /) -> None: ...
@property
def source_tracebacks(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to capture Python source locations during graph construction so runtime errors can be traced back to user code. Takes effect at graph build time and is typically set using ``Graph.debug.source_tracebacks``.
"""
@source_tracebacks.setter
def source_tracebacks(self, arg: bool, /) -> None: ...
@property
def source_tracebacks_hide_internal(self) -> bool:
"""
A boolean that, when ``True`` (the default), cuts the tracebacks that :attr:`source_tracebacks` captures at the call into the graph API, leaving out MAX's implementation of each op, so errors show the code that created it. Set it to ``False`` to keep every frame. Takes effect at graph build time.
"""
@source_tracebacks_hide_internal.setter
def source_tracebacks_hide_internal(self, arg: bool, /) -> None: ...
@property
def pre_jit(self) -> bool:
"""
A boolean that, when ``True``, stops graph compilation once the Mojo for the graph has been emitted (see ``ir_output_dir``), skipping the kernel JIT. ``InferenceSession.compile`` then raises :class:`~max.engine.CompilationStopped`. Takes effect at model build time.
"""
@pre_jit.setter
def pre_jit(self, arg: bool, /) -> None: ...
@property
def op_log_level(self) -> str:
r"""
A string that sets the log level for per-op tracing. One of ``\'\'``, ``'NOTSET'``, ``'TRACE'``, ``'DEBUG'``, ``'INFO'``, ``'WARNING'``, ``'ERROR'``, ``'CRITICAL'``. Takes effect at model build time.
"""
@op_log_level.setter
def op_log_level(self, arg: str, /) -> None: ...
@property
def assert_level(self) -> str:
r"""
A string that sets the Mojo assertion level for compiled kernels. One of ``\'\'``, ``'none'``, ``'warn'``, ``'safe'``, ``'all'``. Higher levels enable more runtime checks at a performance cost. Takes effect at model build time.
"""
@assert_level.setter
def assert_level(self, arg: str, /) -> None: ...
@property
def print_style(self) -> PrintStyle:
"""
A :class:`PrintStyle` value that sets the format for tensor debug printing. Takes effect at run time.
"""
@print_style.setter
def print_style(self, arg: PrintStyle, /) -> None: ...
@property
def ir_output_dir(self) -> str:
"""
A string path to the directory into which MAX dumps intermediate compiler IR for inspection. Empty string disables dumping. Takes effect at model build time.
"""
@ir_output_dir.setter
def ir_output_dir(self, arg: str, /) -> None: ...
@property
def sensible_mode(self) -> bool:
"""
A boolean that, when ``True``, triggers MAX to enable a curated default debugging set, including ``nan_check``, ``assert_level='all'``, ``device_sync_mode``, ``stack_trace_on_error``, ``stack_trace_on_crash``, and ``source_tracebacks``. You can override the defaults using individual properties.
"""
@sensible_mode.setter
def sensible_mode(self, arg: bool, /) -> None: ...
def reset(self) -> None:
"""Resets all debug options to their defaults."""
class InferenceSession:
"""
Manages compilation and execution of MAX models.
An inference session holds device configuration and compiles graphs
into executable :class:`Model` objects. It also manages custom
extensions and debug options.
.. code-block:: python
from max import driver
from max._core.engine import InferenceSession
devices = [driver.CPU()]
session = InferenceSession(devices, custom_extensions=[])
Args:
devices: The devices used for compilation and execution.
custom_extensions: The paths to custom Mojo extension libraries.
num_threads: The number of execution threads. Defaults to 0,
which lets the runtime choose automatically.
"""
def __init__(
self,
devices: Sequence[max._core.driver.Device],
custom_extensions: Sequence[str | os.PathLike],
num_threads: int = 0,
) -> None: ...
def _load_all(
self,
compiled: AsyncValue[CompiledModels],
weights_registry: Mapping[str, Any],
) -> list[Model]: ...
@overload
def compile(
self,
model_path: str | os.PathLike,
custom_extension_paths: Sequence[str | os.PathLike],
) -> max._core.mlrt.AsyncValue[CompiledModels]:
"""
Compiles a model from a file path.
Args:
model_path: The path to the compiled model file (for example, a
``.mef`` file).
custom_extension_paths: The paths to custom Mojo extension
libraries.
Returns:
A handle to the compiled artifact, ready to be initialized with
weights via ``_load_all``.
"""
@overload
def compile(
self,
model: types.CapsuleType,
custom_extensions: Sequence[str | os.PathLike],
pipeline_name: str,
tile_based_fusion: bool = False,
) -> max._core.mlrt.AsyncValue[CompiledModels]:
"""
Compiles a model from an in-memory capsule object.
Args:
model: A capsule containing the compiled model object.
custom_extensions: The paths to custom Mojo extension libraries.
pipeline_name: The name identifier for the compiled pipeline.
tile_based_fusion: When ``True``, compiles the graph under the
tile-based programming model. Defaults to ``False``.
Returns:
A handle to the compiled artifact, ready to be initialized with
weights via ``_load_all``.
"""
def _wrap_compiled(
self, models: CompiledModels
) -> max._core.mlrt.AsyncValue[CompiledModels]:
"""
Wraps an already-read ``CompiledModels`` in a resolved async handle.
Consumes ``models``. The handle is allocated on this session's
runtime and can be passed to :meth:`_load_all`.
"""
def set_debug_print_options(
self, style: PrintStyle, precision: int, directory: str
) -> None:
"""
Sets debug output options for tensor printing during execution.
Args:
style: The output format style.
precision: The number of decimal places for floating-point
values.
directory: The directory path for binary output files.
"""
@overload
def set_mojo_define(self, key: str, value: bool) -> None:
"""
Sets a compile-time Mojo define to a boolean value.
Args:
key: The define name.
value: The boolean value to assign.
"""
@overload
def set_mojo_define(self, key: str, value: int) -> None:
"""
Sets a compile-time Mojo define to an integer value.
Args:
key: The define name.
value: The integer value to assign.
"""
@overload
def set_mojo_define(self, key: str, value: str) -> None:
"""
Sets a compile-time Mojo define to a string value.
Args:
key: The define name.
value: The string value to assign.
"""
@property
def devices(self) -> list[max._core.driver.Device]:
"""The list of devices used by this session."""
debug: DebugConfig
class PrintStyle(enum.Enum):
"""
Controls the output format for debug tensor printing.
Pass one of these values to :meth:`InferenceSession.set_debug_print_options`
to configure how tensors are printed during execution.
"""
COMPACT = 0
"""Compact human-readable format."""
FULL = 1
"""Full verbose format with all tensor details."""
BINARY = 2
"""Raw binary format."""
BINARY_MAX_CHECKPOINT = 4
"""Binary checkpoint format compatible with MAX."""
NONE = 3
"""Disables debug output."""