Using Python APIs to Manage AI Engine Components - 2024.2 English - UG1702

Vitis Reference Guide (UG1702)

Document ID
UG1702
Release Date
2025-01-15
Version
2024.2 English

The Vitis IDE works on the server-client architecture. To create any component you must first create a client object. The component can be created using the create_aie_component API of the client. For more information on using the Python command line interface, see Vitis Interactive Python Shell.

The general steps to manage AI Engine component are as follows:

  1. Create AI Engine Components.

    Use the create_aie_component Python API to create AI Engine components. For example:

    aie_test_comp = client.create_aie_component(name = aie_component, platform=<abs path of xilinx_vck190_base_202420_1.xpfm>, template="empty_aie_component")

    Arguments for the API are as follows:

    name=<aie_component_name>
    Name of the AI Engine component.
    platform=<.xpfm> or <.xsa>
    The hardware design used to compile the AI Engine graph, alternatively the device part is also supported.
    template= "empty_aie_component"
    You can use a component example from the Installed AI Engine Examples as the template. The template value can be defined as "empty" (default), "empty_aie_component", or the location and name of the Installed AI Engine Example you wish to use, such as "installed_aie_examples/simple". For values of "empty" and "empty_aie_component", the AI Engine component will be created from an empty template.
    Note: Double quotes (" ") are required when defining a template value.

    For example, if the AI Engine Example Simple is the template you wish to start with, as shown below:



    The Python API command is as follows:

    aie_test_comp = client.create_aie_component(name = aie_component, platform=<abs path of xilinx_vck190_base_202420_1.xpfm>, template="installed_aie_examples/simple")
  2. Import source files into an AI Engine component.

    Use the import_files Python API to import the source files. For example:

    aie_test_comp.import_files(from_loc = sources_dir, files = ['graph.cpp', 'graph.h', 'kernels.h', 'include.h', 'classify.cc', 'hb27_2i.cc'])

    Arguments for the API are as follows:

    from_loc=<location of source or configuration file>
    The path to the location of the source files can be an absolute path or a relative path to the current working directory. The location can be a directory or a file.
    files=['file1','file2',...]
    List of files to be imported from the from_loc path.
  3. Build AI Engine components.

    Use the build Python API to build AI Engine components. The API supports two targets: hw, and x86sim.

    • To build the component for AI Engine simulator for hardware, use:
      aie_test_comp.build(target="hw")
    • To build the component for x86 simulator, use:
      aie_test_comp.build(target="x86sim")

    The default target is x86sim.