Prepare Data for AI Engine Simulator - 2022.2 English

Vitis Tutorials: AI Engine (XD100)

Document ID
XD100
Release Date
2022-12-01
Version
2022.2 English

Change the working directory to window_aie_mix_int32_float_cint16. The graph code for this example is the same as the Window Based AI Engine Kernels example. The AI Engine kernel core[2] (aie/aie_core3.cpp) has floating point interfaces, and the AI Engine kernel core[3] (aie/aie_core4.cpp) has cint16 interfaces.

When preparing the data for the AI Engnine simulator, all values should be in 32-bit integer format. The conversion is similar to the reinterpret_cast operation in C++. It is done manually in any language. For example, when you want to feed float data 1.0f, 2.0f,…, into the AI Engine kernel, the integer format can be generated in C as shown in the following code.

//input data for float
for(int i=0;i<16;i++){
  float tmp=i;
  printf("%d\n",*(int*)&tmp);
}

Then the data in the input file (data/input.txt) for float, 1.0f,2.0f,…,16.0f, should be as follows.

0
1065353216
1073741824
1077936128
1082130432
1084227584
1086324736
1088421888
1090519040
1091567616
1092616192
1093664768
1094713344
1095761920
1096810496
1097859072

Similarly, type cint16 should be converted to integer type. For example, for cint16 data, {0,0},{4,4},{8,8},…, the integer format can be generated in C as shown in the following code.

//input data for cint16
for(int i=0;i<16;i++){
  int tmp=i*4;
  tmp=tmp<<16;
  tmp+=i*4;
  printf("%d\n",tmp);
}

Then the data in the input file (data/input.txt) for cint16 data, {0,0},{4,4},{8,8},…,{60,60}, should be as follows.

0
262148
524296
786444
1048592
1310740
1572888
1835036
2097184
2359332
2621480
2883628
3145776
3407924
3670072
3932220

Take a look at the input file data/input.txt to see how input data is organized.

Run the following make command to run the AI Engine compiler and simulator.

make aiesim

The output data is in aiesimulator_output/data/output.txt. Similarly, the output data can be converted from integer to float or cint16 to be human-readable.