catalyst.debug.compile_executable¶
- compile_executable(fn, *args)[source]¶
Generate an executable binary for the native host architecture from a
qjit()
decorated function with provided arguments.- Parameters
fn (QJIT) – a qjit-decorated function
*args – argument values to use in the C program when invoking
fn
- Returns
the path of output binary
- Return type
str
Example
For example, considering the following function where we are using
print_memref()
to print (at runtime) information about variabley
:@qjit def f(x): y = x * x debug.print_memref(y) return y
>>> f(5) MemRef: base@ = 0x64fc9dd5ffc0 rank = 0 offset = 0 sizes = [] strides = [] data = 25 Array(25, dtype=int64)
We can now use
compile_executable
to compile this function to a binary.The executable will be saved in the directory for intermediate results if
keep_intermediate=True
. Otherwise, the executable will appear in the Catalyst project root.>>> from catalyst.debug import compile_executable >>> binary = compile_executable(f, 5) >>> print(binary) /path/to/executable
Executing this function from a shell environment:
$ /path/to/executable MemRef: base@ = 0x64fc9dd5ffc0 rank = 0 offset = 0 sizes = [] strides = [] data = 25
code/api/catalyst.debug.compile_executable
Download Python script
Download Notebook
View on GitHub