This example is slightly more difficult. The data is the same but we want zero-padding on dimension 0 and 1 (1 column before and after, 1 row before and after), with 6x6 tiles. We could specify the read access as in test case 1 including the zero-padding, but we know by advance that we won’t have enough BDs.
A solution is to chain 2 memory tiles, the first one reading the layers one by one, and the second performing the zero-padding and the 6x6 tiling.
// Connections
adf::connect(din, mtxin1.in[0]);
adf::write_access(mtxin1.in[0]) = adf::tiling({
.buffer_dimension = {D0123},
.tiling_dimension = {D0123},
.offset = {0},
.tile_traversal = {}});
// Original data sent layer by layer
adf::connect(mtxin1.out[0], mtxin2.in[0]);
adf::read_access(mtxin1.out[0]) = adf::tiling({
.buffer_dimension = {Dim0, Dim1, D23}, // 8x8x16
.tiling_dimension = {(Dim0 ), (Dim1),1}, // 8x8x1
.offset = {0, 0,0},
.tile_traversal = {
{.dimension = 2, .stride = 1, .wrap = D23}}});
adf::write_access(mtxin2.in[0]) = adf::tiling({
.buffer_dimension = {D01},
.tiling_dimension = {D01},
.offset = {0},
.tile_traversal = {}});
// Original data zero padded around, split in 4 tiles
adf::connect(mtxin2.out[0], k1.in[0]);
adf::read_access(mtxin2.out[0]) = adf::tiling({
.buffer_dimension = {Dim0, Dim1}, // 8x8
.tiling_dimension = {(Dim0/2+2), (Dim1/2+2)}, // 6x6
.offset = {-1,-1},
.tile_traversal = {
{.dimension = 0, .stride = Dim0/2, .wrap = 2},
{.dimension = 1, .stride = Dim1/2, .wrap = 2}}});
adf::connect(k1.out[0], dout[0]);
Let’s compile and simulate:
make SECTION=memtile T3 aie aiesim
The graph being created can be visualized in Vitis Analyzer:
Here are the extracted tiles from the original data set. The first 4 tiles are the 4 quarters of the first layer of the first image, the following 4 tiles are the 4 quarters of the second layer of the first image and so on. On all these quarters we can observe the zero-padding.
Utils/GetTiles.py memtile_aiesimulator_output/data/NoStamps_Output_0.txt 2D 6 6 0 7
------------------------------------------------------
filename: memtile_aiesimulator_output/data/NoStamps_Output_0.txt
NCols: 6
NRows: 6
NLayers: 1
NImages: 1
------------------------------------------------------
Static Tile Selection
Tile: 0
0 0 0 0 0 0
0 0 1 2 3 4
0 10 11 12 13 14
0 20 21 22 23 24
0 30 31 32 33 34
0 40 41 42 43 44
------------------------------------------------------------
Tile: 1
0 0 0 0 0 0
3 4 5 6 7 0
13 14 15 16 17 0
23 24 25 26 27 0
33 34 35 36 37 0
43 44 45 46 47 0
------------------------------------------------------------
Tile: 2
0 30 31 32 33 34
0 40 41 42 43 44
0 50 51 52 53 54
0 60 61 62 63 64
0 70 71 72 73 74
0 0 0 0 0 0
------------------------------------------------------------
Tile: 3
33 34 35 36 37 0
43 44 45 46 47 0
53 54 55 56 57 0
63 64 65 66 67 0
73 74 75 76 77 0
0 0 0 0 0 0
------------------------------------------------------------
Tile: 4
0 0 0 0 0 0
0 100 101 102 103 104
0 110 111 112 113 114
0 120 121 122 123 124
...