Skip to content

Instantly share code, notes, and snippets.

error: the actual and expected result matrices disagree at row 7, column 5.
actual value: 0
expected value: -24
left-hand side (rows 0..7 out of 0..7, columns 0..7 out of 0..7)
96 -48 126 36 -107 83 -3 -97
-52 41 45 127 62 120 -100 66
43 -37 -23 69 -40 126 -77 -100

Command line:

iree/tools/iree-translate -iree-mlir-to-vm-bytecode-module -mlir-print-op-on-diagnostic=false --iree-hal-target-backends=dylib-llvm-aot /tmp/a.mlir -o /tmp/a.vmfb -iree-llvm-embedded-linker-path=third_party/llvm-project/llvm/bin/lld

Output:

/tmp/a.mlir:10:8: error: 'linalg.tensor_expand_shape' op expected dimension 0 of collapsed type to be dynamic since one or more of the corresponding dimensions in the expanded type is dynamic
// -----// IR Dump After mlir::iree_compiler::Shape::(anonymous namespace)::ExpandFunctionDynamicDimsPass //----- //
module {
func @f(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.abi.stub} {
%c5 = arith.constant 5 : index
%c3 = arith.constant 3 : index
%c0_i8 = arith.constant 0 : i8
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
%0 = hal.tensor.cast %arg0 : !hal.buffer_view -> tensor<1x1xi8>
%1 = linalg.pad_tensor %0 low[0, 0] high[%c5, %c3] {
diff --git a/iree/compiler/Dialect/Flow/Transforms/PadTensorToSubTensorInsert.cpp b/iree/compiler/Dialect/Flow/Transforms/PadTensorToSubTensorInsert.cpp
index 7f3ad376e..362d4df27 100644
--- a/iree/compiler/Dialect/Flow/Transforms/PadTensorToSubTensorInsert.cpp
+++ b/iree/compiler/Dialect/Flow/Transforms/PadTensorToSubTensorInsert.cpp
@@ -90,8 +90,10 @@ struct PadTensorOpConversion : public OpRewritePattern<linalg::PadTensorOp> {
Value fill =
rewriter.create<linalg::FillOp>(loc, yieldVal, initTensor).getResult(0);
SmallVector<OpFoldResult> strides(rank, rewriter.getI64IntegerAttr(1));
- rewriter.replaceOpWithNewOp<tensor::InsertSliceOp>(
- padTensorOp, source, fill, lowPad, sourceShape, strides);
This file has been truncated, but you can view the full file.
// -----// IR Dump After mlir::iree_compiler::IREE::ABI::WrapEntryPointsPass //----- //
#map0 = affine_map<(d0, d1, d2, d3) -> (d0, d2, d1, d3)>
#map1 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
#map2 = affine_map<(d0, d1, d2, d3) -> (d1, d3, d0, d2)>
module {
func @matmul_123x456xi8_times_456x789xi8_into_123x789xi32(%arg0: !hal.buffer_view, %arg1: !hal.buffer_view, %arg2: !hal.buffer_view) -> !hal.buffer_view attributes {iree.abi.stub} {
%0 = hal.tensor.cast %arg0 : !hal.buffer_view -> tensor<123x456xi8>
%1 = hal.tensor.cast %arg1 : !hal.buffer_view -> tensor<456x789xi8>
%2 = hal.tensor.cast %arg2 : !hal.buffer_view -> tensor<123x789xi32>
%3 = call @_matmul_123x456xi8_times_456x789xi8_into_123x789xi32(%0, %1, %2) : (tensor<123x456xi8>, tensor<456x789xi8>, tensor<123x789xi32>) -> tensor<123x789xi32>
@bjacob
bjacob / README.md
Last active November 6, 2021 01:50
benoitjacob@desk:~$ cc -DM0=8 -DK0=4 -DN0=8 -DMMT4D_VARIANT_GENERIC mmt4dkernels.c -o /tmp/mmt4dkernels && /tmp/mmt4dkernels
called kernel: mmt4d_kernel_generic_8x4x8
57 30 63 45 27 45 33 42 
60 27 60 51 24 39 33 60 
60 24 66 45 36 42 36 33 
54 30 54 51 24 60 18 48 
69 45 66 57 18 54 39 48 
33 18 42 39 18 30 12 36 
72 39 63 63 30 66 39 51 
benoitjacob@cloud:~/iree-build-linux$ iree/tools/iree-translate -iree-mlir-to-vm-bytecode-module -mlir-print-op-on-diagnostic=false --iree-hal-target-backends=dylib-llvm-aot a.mlir -o /usr/local/google/home/benoitjacob/iree-build-linux/iree/test/e2e/regression/e2e_matmul_mmt4d_f32_large_dylib-llvm-aot_dylib.vmfb -iree-llvm-embedded-linker-path="/usr/local/google/home/benoitjacob/iree-build-linux/third_party/llvm-project/llvm/bin/lld" -print-ir-after-all

// -----// IR Dump After mlir::iree_compiler::Shape::(anonymous namespace)::ExpandFunctionDynamicDimsPass //----- //
module  {
  func @matmul_123x456xf32_times_456x789xf32_into_123x789xf32(%arg0: !hal.buffer_view) -> !hal.buffer_view attributes {iree.abi.stub} {
    %c5 = arith.constant 5 : index
    %c0 = arith.constant 0 : index
    %cst = arith.constant 0.000000e+00 : f32
    %c2 = arith.constant 2 : index
commit 75f1a3862cf6d099e850fca6afe31a910cd8cbe5
Author: Benoit Jacob <[email protected]>
Date: Wed Jun 9 16:35:14 2021 -0400
wip
forfkorfkr
diff --git a/mlir/include/mlir/Conversion/Passes.h b/mlir/include/mlir/Conversion/Passes.h
index f3f8687984fc..cad5b2713c8e 100644
#map0 = affine_map<(d0, d1, d2, d3) -> (d0, d2, d1, d3)>
#map1 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
#map2 = affine_map<(d0, d1, d2, d3) -> (d1, d3, d0, d2)>
module {
func @matmul_8x8xi8_times_8x8xi8_into_8x8xi32(%arg0: tensor<8x8xi8>, %arg1: tensor<8x8xi8>, %arg2: tensor<8x8xi32>) -> tensor<8x8xi32> {
%0 = linalg.tensor_expand_shape %arg0 [[0, 1], [2, 3]] : tensor<8x8xi8> into tensor<1x8x2x4xi8>
%1 = linalg.tensor_expand_shape %arg1 [[0, 1], [2, 3]] : tensor<8x8xi8> into tensor<2x4x1x8xi8>
%2 = linalg.tensor_expand_shape %arg2 [[0, 1], [2, 3]] : tensor<8x8xi32> into tensor<1x8x1x8xi32>
%3 = linalg.init_tensor [1, 2, 8, 4] : tensor<1x2x8x4xi8>
%4 = linalg.generic {indexing_maps = [#map0, #map1], iterator_types = ["parallel", "parallel", "parallel", "parallel"]} ins(%0 : tensor<1x8x2x4xi8>) outs(%3 : tensor<1x2x8x4xi8>) {
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_1x1xi8_times_1x1xi8_into_1x1xi32] ---
--- CALL[module.matmul_1xDYNxi8_times_DYNx1xi8_into_1x1xi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---
--- CALL[module.matmul_DYNxDYNxi8_times_DYNxDYNxi8_into_DYNxDYNxi32] ---