Repository navigation
[LLVMCPU] Peel instead of masking for sub-byte operands - #25200
roberto-laudani wants to merge 1 commit into
Conversation
Signed-off-by: Roberto Laudani <[email protected]>
943d5ab to
1299780
Compare
egebeysel
left a comment
There was a problem hiding this comment.
Generally in the good direction, though there is one correctness issue that this PR surfaces (for AArch64 NEON which already gets a peeling config, this issue was already there), see my inline comment for the e2e test.
Furthermore, #25203 says that loops with dynamic trip counts do not compile, and this would not necessarily fix that, right?:
tensor<?xi4>: the peeled remainder has a runtime size, so it's still masked and still hits the same error.- Static shapes split across workgroups: e.g. tensor with workgroup tile M with
N % M != 0. Each wg has the extentaffine.min(N - off, M), which isn't a constant. The remainder inside a workgroup is therefore masked again. setTransposeLikeOpRootConfigdoes not set the peeling config so if it's realistic to get an i4 transpose, that wouldn't be handled.
| // sub-byte elements once their masks are lowered, so peel. Remainders of | ||
| // dynamic size are still masked. |
There was a problem hiding this comment.
where exactly does this happen? can you also write a test to showcase/test that setting the peeling attr gets that pass to succeed (explicitly as a "unit" test instead of the e2e test)?
| ]> : tensor<34xi4> | ||
| %0 = tensor.empty() : tensor<34xf32> | ||
| %res = linalg.generic {indexing_maps = [affine_map<(d0) -> (d0)>, affine_map<(d0) -> (d0)>], iterator_types = ["parallel"]} | ||
| ins(%input : tensor<34xi4>) outs(%0 : tensor<34xf32>) { |
There was a problem hiding this comment.
%res = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d1)>, affine_map<(d0, d1) -> (d0, d1)>], iterator_types = ["parallel", "parallel"]} ins(%3, %4 : tensor<128x70xi4>, tensor<70xf32>) outs(%5 : tensor<128x70xf32>) {
^bb0(%in: i4, %in_0: f32, %out: f32):
%7 = arith.sitofp %in : i4 to f32
%8 = arith.mulf %7, %in_0 : f32
linalg.yield %8 : f32
} -> tensor<128x70xf32>This would pick tile sizes distribution = [128, 35], vector_parallel = [1, 4] and silently miscompile and produce wrong results on rows 35-66. We should also make sure to get byte-aligned tiles.
Fixes #25203
Narrow-type emulation cannot rewrite masked loads and stores of packed sub-byte elements once
vector.create_maskis lowered.getVectorPreProcStrategynow selects peeling for linalg ops with packed sub-byte operands, so static shapes need no mask.Assisted by: Claude