The Vitis Unified IDE supports Python APIs
to create and build an AI Engine component. You can either create and build the component through the GUI (see
Creating an AI Engine Component in the
AI
Engine Tools and Flows User Guide (UG1076)) or using Python APIs. Some of the Python APIs that are required
to create and build AI Engine
components are shared in the following table. For details of all Vitis supported Python APIs, refer to the link: <vitis_install_path>cli/api_docs/build/html/vitis.html. Multiple
config files are not supported in the Vitis IDE to create
the component. If you would like to use a custom config file to create the component,
remove the config file generated by the Vitis tool
(default) as shown below:
The Python script to create an AI Engine component and build for
- Remove the tool generated configuration file using the Python
command:
remove_cfg_file('<config_file.cfg>') - Add the custom configuration file using the Python command:
add_cfg_file('<custom_config_file.cfg>')
| Python API | Description | Python API Example |
|---|---|---|
create_aie_component
|
Create an AI Engine Component |
aie_comp=client.create_aie_component(name=my_component,
platfrom=<.xpfm or .xsa>,
template="empty")
|
import_files
|
Import files to the AI Engine component | To import files:
To import folders: aie_comp.import_files(from_loc="<input_folder_path>)
|
add_cfg_file
|
Add configuration file to the AI Engine component |
aie_comp.add_cfg_file('<.cfg file
path'>)
|
remove_cfg_file
|
Remove configuration file from the component. |
aie_comp.remove_cfg_file('<.cfg file>')
|
update_top_level_file
|
Update the top level file of AI Engine component |
aie_comp.update_top_level_file('<main_graph>.cpp')
|
build
|
Initiate the build of AI Engine Component for x86 and AIESIM/HW |
For x86 simulator (default): For hardware: |
report
|
Print the component information |
aie_comp.report()
|
clean
|
Clean the AI Engine component for the specified build target |
aie_comp.clean(target=<hw OR x86sim>)
|
target=Hardware is described
below:# Add package: Vitis Python CLI
import vitis
# Create a Vitis client object -
client = vitis.create_client()
# Set Vitis Workspace
client.set_workspace(path=<workspace_location>)
# 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 = ['file1.cpp', 'file2.h', 'file3.h', 'kernel1.cc', 'kernel2.cc'])
# Set top file from the imported source
aie_test_comp.update_top_level_file(top_level_file = 'main_graph.cpp')
# Build component on target Hardware
aie_test_comp.build(target="hw")
# Print component information
aie_test_comp.report()
After the build, the AI Engine component outputs (libadf.a, Work folder etc.) are created at: <workspace>/<comp_name>/build/hw/