Programming Model Features - Programming Model Features - 2026.1 English - UG1603

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
UG1603
Release Date
2026-07-08
Version
2026.1 English

The AI Engine-ML programming model has the following features.

  • All I/O objects (input_plio/output_plio and input_gmio/output_gmio) are public members of graph class. Looping through I/O objects is supported. This makes coding easier and less error prone. For example:
    class mygraph : public adf::graph
    {
    public:
        // Declare N kernels.
        adf::kernel k[N];
        // Declare N input_gmio(s) and output_gmio(s)
        adf::input_gmio gmioIn[N];
        adf::output_gmio gmioOut[N];
    
        mygraph()
        {
            // Create multiple input_gmio(s)/output_gmio(s) and connections
            for (int i=0; i<N; i++)
            {
                gmioIn[i]  = adf::input_gmio::create("gmioIn" + std::io_string(i), 64, 1);
                gmioOut[i] = adf::output_gmio::create("gmioOut" + std::io_string(i), 64, 1);
                adf::connect(gmioIn[i].out[0], k[i].in[0]);
                adf::connect(k[i].out[0], gmioOut[i].in[0]);
            }
        }
    };
    Note: A logical name can be specified with the input_plio, output_plio, input_gmio and output_gmio objects. If you do not specify a logical name, the AI Engine compiler automatically sets a unique logical name.
  • The programming model provides ease-of-use for connections within the design. With the input_plio, output_plio, input_gmio and output_gmio objects in the local scope, connect<> calls are not required to provide a unique connection name.
  • The programming model supports the direction property of input_plio, output_plio, input_gmio and output_gmio objects. Object construction determines the direction property.

An example of the programming model that addresses these previously listed features is as follows.

/* A graph with both PLIO and GMIO*/
class mygraph : adf::graph
{
public:

    /* Classes support input_gmio/output_gmio and input_plio/output_plio */
    adf::input_gmio gm_in; 
    adf::output_gmio gm_out;

    adf::input_plio pl_in;
    adf::output_plio pl_out;

    adf::kernel k1, k2;
    mygraph()
    {
        k1 = adf::kernel::create(...);
        k2 = adf::kernel::create(...);

        /* create() API for PLIO and GMIO objects support same arguments specified as in global scope */
        gm_in = adf::input_gmio::create("GMIO_In0",/*const std::string& logical_name*/
                                    64,       /*size_t burst_length*/
                                    1         /*size_t bandwidth*/);

        gm_out = adf::output_gmio::create("GMIO_Out0", 64, 1);

        pl_in = adf::input_plio::create("PLIO_In0",       /* std::string logical_name */
                                    adf::plio_32_bits,    /* enum plio_type plio_width */
                                    "data/input.txt",/* std::string data_file */
                                    250.0            /* double frequency */ );

        pl_out = adf::output_plio::create("PLIO_Out0", adf::plio_32_bits, "data/output.txt", 250.0);

        /* Each input_gmio/output_gmio and input_plio/output_plio supports 1 port per direction */
        adf::connect(gm_in.out[0], k1.in[0]);
        adf::connect(k1.out[0], gm_out.in[0]);

        adf::connect(pl_in.out[0], k2.in[0]);
        adf::connect(k2.out[0], pl_out.in[0]);

        adf::location<adf::GMIO>(gm_in) = adf::shim(col);
        adf::location<adf::GMIO>(gm_out) = adf::shim(col, ch_num); /* not supported */

        adf::location<adf::PLIO>(pl_in) = adf::shim(col);
        adf::location<adf::PLIO>(pl_out) = adf::shim(col, ch_num);
    }

};

The preceding code snippet shows the following:

  • input_plio, output_plio, input_gmio, and output_gmio are public objects within the graph.
  • input_plio, and output_plio classes are inherited from the PLIO class.
  • input_gmio, and output_gmio classes are inherited from the GMIO class.
  • input_plio, output_plio, input_gmio, and output_gmio object constructions contain the direction property.
  • connect call does not require a unique name.
  • Location constraints can be applied to the input_plio, output_plio, input_gmio, and output_gmio objects directly with the exception of GMIO channel constraints which are not supported in this release.
    Note: GMIO shim tile location constraint with DMA channel is not supported.
    Note: Host application calling profiling APIs need reference object’s public members, mygraph.gm_in, mygraph.gm_out, mygraph.pl_in, mygraph.pl_out. For additional details about profiling APIs, refer to Performance Analysis of AI Engine Graph Application during Simulation in the AI Engine Tools and Flows User Guide (UG1076).

    Following is an example of a profile call from the programming model.

    event::handle handle0 = event::start_profiling(mygraph.gm_in, event::io_stream_start_to_bytes_transferred_cycles, sizeIn*sizeof(cint16));
Important: The input_plio, output_plio, input_gmio, and output_gmio objects must have unique names. If the names are not unique, an error message similar to the following is issued:
ERROR: [aiecompiler 77-4551] The logical name DataIn1 of node i6 conflicts with the logical/qualified name of node i0.