There are several options that exist to configure the IRON Python programming environment.
This is a variable that controls the types of aie.utils.Tensors that are produced by the utility functions tensor, ones, etc. Right now there are two tensor implementations: CPUOnlyTensor and XRTTensor.
By default, if pyxrt is available, the DEFAULT_TENSOR_CLASS is set to XRTTensor. However, you can also manually set this value through the set_tensor_class(), e.g.:
>>> import numpy as np
>>> print(aie.utils.tensor.DEFAULT_TENSOR_CLASS.__name__)
XRTTensor
>>> type(iron.tensor((2, 2), np.int32))
<class 'aie.utils.xrtruntime.tensor.XRTTensor'>
>>> aie.utils.set_tensor_class(aie.utils.tensor.CPUOnlyTensor)
>>> print(aie.utils.tensor.DEFAULT_TENSOR_CLASS.__name__)
CPUOnlyTensor
>>> type(aie.utils.tensor((2, 2), np.int32))
<class 'aie.utils.tensor.CPUOnlyTensor'>If the IRON device is not set, many designs will try it fetch it on demand using the utility function detect_npu_device(). However, this can be overriden by calling the set_current_device() function, which takes as an argument the new device and returns the previous device:
>>> import aie.iron as iron
>>> iron.set_current_device(iron.device.NPU1())
<abc.NPU2 object at 0x722a659826c0>
>>> iron.get_current_device()
<abc.NPU1 object at 0x722a65903a10>The IRON jit feature caches compiled objects in a directory defined by NPU_CACHE_DIR. By default this value is the user's home directory.
The CachedXRTRuntime caches XRT contexts to improve performance. The size of this cache can be configured using the XRT_CONTEXT_CACHE_SIZE environment variable. This is particularly useful in CI environments where multiple tests run in parallel and might exhaust the available NPU contexts.
export XRT_CONTEXT_CACHE_SIZE=1The aie library uses Python's standard logging module for all diagnostic output. Set
AIE_LOG_LEVEL to control verbosity. Valid values: DEBUG, INFO, WARNING
(default), ERROR, CRITICAL.
AIE_LOG_LEVEL=DEBUG python my_script.py # show debug messages
AIE_LOG_LEVEL=INFO python my_script.py # show info and above
AIE_LOG_LEVEL=ERROR python my_script.py # errors onlyFor per-module control or routing to a file, use the logging API directly:
import logging
logging.getLogger("aie").setLevel(logging.ERROR)
# Route aie logs to a file instead of the console
handler = logging.FileHandler("aie.log")
handler.setFormatter(logging.Formatter("%(asctime)s %(name)s %(levelname)s %(message)s"))
logging.getLogger("aie").addHandler(handler)
logging.getLogger("aie").propagate = False # don't also send to root logger