Repository navigation
Closed
Labels
Description
This is blocking enabling i8 matmul e2e tests with vmvx microkernels enabled (#9904)
Testcase a.mlir:
func.func @matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32(%lhs: tensor<?x?xi8>, %rhs: tensor<?x?xi8>, %acc: tensor<?x?xi32>) -> tensor<?x?xi32> {
%result = linalg.matmul ins(%lhs, %rhs: tensor<?x?xi8>, tensor<?x?xi8>) outs(%acc: tensor<?x?xi32>) -> tensor<?x?xi32>
return %result: tensor<?x?xi32>
}
Repro:
$ tools/iree-compile --output-format=vm-bytecode --mlir-print-op-on-diagnostic=false --iree-hal-target-backends=vmvx --iree-vmvx-enable-microkernels /tmp/a.mlir -o /tmp/a.vmfb
/tmp/a.mlir:2:13: error: operand #1 does not dominate this use
%result = linalg.matmul ins(%lhs, %rhs: tensor<?x?xi8>, tensor<?x?xi8>) outs(%acc: tensor<?x?xi32>) -> tensor<?x?xi32>
^
/tmp/a.mlir:1:1: note: called from
func.func @matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32(%lhs: tensor<?x?xi8>, %rhs: tensor<?x?xi8>, %acc: tensor<?x?xi32>) -> tensor<?x?xi32> {
^
/tmp/a.mlir:2:13: note: operand defined here (op in the same block)
%result = linalg.matmul ins(%lhs, %rhs: tensor<?x?xi8>, tensor<?x?xi8>) outs(%acc: tensor<?x?xi32>) -> tensor<?x?xi32>
^
/tmp/a.mlir:2:13: error: failed to run translation of source executable to target executable for backend #hal.executable.target<"vmvx", "vmvx-bytecode-fb">
%result = linalg.matmul ins(%lhs, %rhs: tensor<?x?xi8>, tensor<?x?xi8>) outs(%acc: tensor<?x?xi32>) -> tensor<?x?xi32>
^
/tmp/a.mlir:1:1: note: called from
func.func @matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32(%lhs: tensor<?x?xi8>, %rhs: tensor<?x?xi8>, %acc: tensor<?x?xi32>) -> tensor<?x?xi32> {
^
/tmp/a.mlir:2:13: error: failed to serialize executables
%result = linalg.matmul ins(%lhs, %rhs: tensor<?x?xi8>, tensor<?x?xi8>) outs(%acc: tensor<?x?xi32>) -> tensor<?x?xi32>
^
/tmp/a.mlir:1:1: note: called from
func.func @matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32(%lhs: tensor<?x?xi8>, %rhs: tensor<?x?xi8>, %acc: tensor<?x?xi32>) -> tensor<?x?xi32> {
^
compilation failed
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
bjacob commentedon Jul 26, 2022
@benvanik @stellaraccident
benvanik commentedon Jul 26, 2022
Can you post the
--mlir-print-ir-after-all? (I can look at this later but may be able to spot the issue here)bjacob commentedon Jul 27, 2022
https://gist.github.com/bjacob/4b5e102f75b9f58661e63f68dab45182
benvanik commentedon Jul 27, 2022
Looks like a bug in memref subview handling:
%34 = "arith.muli"(%arg0, %44) : (index, index) -> index(using %44 before it is defined) /cc @stellaraccidentbenvanik commentedon Jul 27, 2022
May be the memref.dims getting inserted in the wrong order.
benvanik commentedon Jul 27, 2022
ok, found a fix (though it may not be right); issue is that this code doesn't set a builder to the right place:
https://github.com/google/iree/blob/main/compiler/src/iree/compiler/Codegen/VMVX/LowerLinalgMicrokernels.cpp#L227-L228
I've got that patched and now can lower all the way to the end where we bail because there's no vmvx.matmul.i8i8i32! 🥳
Here's the IR after translation:
Setting insertion point for memref subview expansion.
Setting insertion point for memref subview expansion. (#9917)
bjacob commentedon Aug 17, 2022
The originally reported failure mode is indeed fixed, but the original testcase (PR description above) still reproduces some other failure:
bjacob commentedon Aug 17, 2022
Looks like a much milder failure now, basically just hinting to implement the missing
vmvx.matmul.i8--- doing it!stellaraccident commentedon Aug 17, 2022
Thanks! Yes, I hadn't yet specialized anything outside of f32 (and int 32 for elementwise). Go for it.
Add e2e matmul tests on vmvx+ukernels (float32-only for now) (#10193)
Squashed commit of the following: