Beginner Examples¶
The beginner examples introduce the common shape of a PyPTO-Lib executable:
- declare a
@pl.jitkernel; - divide the problem into
pl.paralleltiles; - perform work inside a
pl.atcore-group scope; - describe inputs and outputs with Golden Harness specs;
- compare the device or simulator result with a Torch reference.
Both examples accept -p {a2a3,a2a3sim,a5,a5sim}. Repository CI exercises
a2a3, a2a3sim, and a5sim.
Hello World¶
hello_world.py adds one scalar to every element of an FP32 matrix. It is the
smallest example that shows the complete path from a tensor signature to
validated output.
Pay attention to:
pl.paralleldistributing row tiles across core groups;pl.rangewalking column tiles within each row tile;- a tensor slice becoming the tile consumed by
pl.add; ScalarSpecandTensorSpecdescribing the test fixture.
Run it on the A2/A3 simulator:
Matmul¶
matmul.py computes an FP32 matrix multiplication with M and N tiling. The K
dimension fits in one tile, making this a useful first cube example before
adding a reduction loop.
Pay attention to:
- nested
pl.parallelloops selecting output tiles; - slicing A and B to match the output tile;
pl.matmulproducing one tile of C;- the tolerance passed to the Golden Harness.
Run it on the A5 simulator:
Next step¶
Continue with GEMM, which adds K tiling and
pl.matmul_acc, then compare the normalization examples to see how row
reductions and broadcasts are expressed.