This document provides an overview of the imports used when writing Exo.
Exo's parser only resolves names in the local and global namespaces, and Exo reserves the attribute syntax (foo.bar) for configurations. Therefore, if users wish to utilize Exo constructs, they must import them into their local namespace.
- Standard Python Future Import
- Core Exo Module
- Memory Libraries
- Instruction Libraries
- Extern Libraries
- Frontend Syntax Utilities
- Standard Library Scheduling Functions
- API Cursors
from __future__ import annotations
Enables postponed evaluation of type annotations, allowing you to use forward references in type hints without causing issues during runtime. This is necessary to support Exo's x : f32
syntax.
from exo import *
Imports basic classes and functions necessary for defining and manipulating high-performance computational kernels, such as proc
, instr
, config
, Memory
, Extern
, DRAM
, and SchedulingError
.
Even though users can define memory definitions externally to the compiler in the user code (see memories.md), we provide memory definitions for some architectures for convinience.
The supported memory definitions can be found by looking into src/exo/libs/memories.py
.
from exo.libs.memories import DRAM_STATIC, AVX2, AVX512
For example, you can import DRAM_STATIC
, AVX2
, or AVX512
as shown above.
Similar to memories, we provide some hardware instruction definitions for convinience (see instructions.md to learn how to define your own accelerator instructions).
from exo.platforms.x86 import mm256_loadu_ps, mm256_setzero_ps, mm256_broadcast_ss
Similary, convinience extern libraries can be imported as follows. See externs.md to learn how to define your own externs.
from exo.libs.externs import sin, relu
from exo.frontend.syntax import *
This module defines special symbols that are used inside Exo code. Importing this can suppress warnings inside an IDE (like PyCharm).
Exo provides users with the ability to define new scheduling operations using Cursors. For convenience, we have implemented scheduling libraries (standard library) that contain common scheduling operations users may want to use, such as vectorization and tiling. Users can import the standard library as follows:
from exo.stdlib.scheduling import repeat, replace_all
from exo.stdlib.stdlib import vectorize, tile_loops
Alternatively, users can define their own scheduling operations by composing scheduling primitives directly in their code.
Cursors (see Cursors.md) are Exo's reference mechanism that allows users to navigate and inspect object code. When users define new scheduling operators using Cursors, they may wish to write their own inspection pass (see inspection.md). API Cursors define types that will be useful for user inspection.
from exo.API_cursors import ForCursor, AssignCursor, InvalidCursor
These API Cursors provide specific types, such as ForCursor
for for-loops, AssignCursor
for assignments, and InvalidCursor
for invalid cursors. Users can leverage these types when inspecting and manipulating code using Cursors.