Using APIs in a Python Script - 2024.1 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
Release Date
2024.1 English

The Python package vitis which includes all Python APIs must be added in the Python script. The example below uses the Python APIs in a Python script to manage an AI Engine component:

# Add package: Vitis Python CLI
import vitis

# Create a Vitis client object -
client = vitis.create_client()

# Set Vitis Workspace

# Create aie component.
aie_test_comp = client.create_aie_component(name = comp_name, platform = <absolute path of platform>, template = "empty_aie_component")

# Import source files to the component
aie_test_comp.import_files(from_loc = <absolute path of source folder>, files = ['graph.cpp', 'graph.h', 'kernels.h', 'include.h', '', ''])

# Set top file from the imported source
aie_test_comp.update_top_level_file(top_level_file = 'graph.cpp')

# Build component on target Hardware"hw")

# Print component information

The following command launches the Vitis IDE, and executes the python script:

vitis -s

The vitis -s command manages the Vitis component (such as, creation, build, editing configuration files, etc.). Following that, you can launch the Vitis IDE and display the AI Engine components in the workspace using the vitis -w command.

vitis -w <workspace_location>
The AI Engine component is created, the libadf.a is generated, and the component build is completed successfully.

To simulate and debug the AI Engine component, refer to the next section.