| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
""" |
| 26 |
ValidMatrixInstruction |
| 27 |
--- |
| 28 |
Format: (M x N x K x B) |
| 29 |
XDLOPS tile definition, only valid for gfx908, gfx90a |
| 30 |
MxNxKxB specifies matrix instruction variants |
| 31 |
MxNxB determines the shape of the C tile each instruction worked on |
| 32 |
K determines the unroll depth |
| 33 |
|
| 34 |
Alternative format: (M x N x K x B x MIBlockM x WaveTileM x WaveTileN x WaveM x WaveN) |
| 35 |
(Note: MxN means M-by-N in the following comments) |
| 36 |
MIBlockM determines how many blocks along M dimension for multi-block MI variants. Concrete examples: |
| 37 |
- MI 16x16x1x4 (4-block variant) with MIBlockM=4 -> (16x16)*(4x1)=64x16 tile per instruction executed |
| 38 |
- MI 32x32x1x2 (2-block variant) with MIBlockM=1 -> (32x32)*(1x2)=32x64 tile per instruction executed |
| 39 |
WaveTileM/N are dimensions of the C tile each wave works on, and is close to the concept of ThreadTile in classic VALU kernels |
| 40 |
- WT 4x1 -> each wave executes 4x1 matrix instructions on the C tile of total area (4*MITileM)x(1*MITileN) |
| 41 |
WaveM/N are dimensions of waves spawned for one workgroup where each wave consists of 64 threads |
| 42 |
- Wave2x2 -> a total of 4 waves in one workgroup of shape 2x2 |
| 43 |
Putting it all together: |
| 44 |
- [32, 32, 1, 2, 1, 4, 1, 2, 2] |
| 45 |
^^^^^^^^^^^^ ^ ^^^^ ^^^^ |
| 46 |
MatrixInst BlkM WT Wave |
| 47 |
- means (32x64) per MI * (4x1) per wave * (2x2) per workgroup = (32*4*2)x(64*1*2) = 256x128 macro tile |
| 48 |
Tensile will ignore the parameters ThreadTile and WorkGroup when the alternative format is used |
| 49 |
|
| 50 |
Notes: |
| 51 |
- If empty, do not use these instructions |
| 52 |
""" |
| 53 |
|
| 54 |
from typing import Dict |
| 55 |
from pathlib import Path |
| 56 |
|
| 57 |
from Tensile.Common import IsaVersion, IsaInfo, elineno |
| 58 |
from Tensile.SolutionStructs.Validators.MatrixInstruction import validateMIParameters |
| 59 |
|
| 60 |
|
| 61 |
def _validateMatrixInstruction( |
| 62 |
solution: dict, isaInfoMap: Dict[IsaVersion, IsaInfo], filepath: Path |
| 63 |
) -> bool: |
| 64 |
try: |
| 65 |
validateMIParameters(solution, isaInfoMap) |
| 66 |
assert solution["Valid"], f"Solution was rejected: {elineno()}" |
| 67 |
return True |
| 68 |
except AssertionError as e: |
| 69 |
print( |
| 70 |
f"Error: Validation failed: {e} (file: {filepath}, index: {solution['SolutionIndex']})" |
| 71 |
) |
| 72 |
return False |