53 lines · plain
1// RUN: mlir-opt %s -generate-runtime-verification | FileCheck %s2// RUN: mlir-opt %s --generate-runtime-verification="verbose-level=0" | FileCheck %s --check-prefix=VERBOSE03 4// Most of the tests for linalg runtime-verification are implemented as integration tests.5 6#identity = affine_map<(d0) -> (d0)>7 8// CHECK-LABEL: @static_dims9// VERBOSE0-LABEL: @static_dims10func.func @static_dims(%arg0: tensor<5xf32>, %arg1: tensor<5xf32>) -> (tensor<5xf32>) {11 // CHECK: %[[TRUE:.*]] = index.bool.constant true12 // CHECK: cf.assert %[[TRUE]]13 // VERBOSE0: %[[TRUE:.*]] = index.bool.constant true14 // VERBOSE0: cf.assert %[[TRUE]]15 // VERBOSE0-SAME: ERROR: Runtime op verification failed\0A^ unexpected negative result on dimension #016 // VERBOSE0-SAME: Location 17 // VERBOSE0-SAME: 19:10 18 %result = tensor.empty() : tensor<5xf32> 19 %0 = linalg.generic {20 indexing_maps = [#identity, #identity, #identity],21 iterator_types = ["parallel"]22 } ins(%arg0, %arg1 : tensor<5xf32>, tensor<5xf32>)23 outs(%result : tensor<5xf32>) {24 ^bb0(%gen_arg1: f32, %gen_arg2: f32, %out: f32) :25 %tmp1 = arith.addf %gen_arg1, %gen_arg2 : f3226 linalg.yield %tmp1 : f3227 } -> tensor<5xf32>28 return %0 : tensor<5xf32>29}30 31// -----32 33#map = affine_map<() -> ()>34 35// CHECK-LABEL: @scalars36// VERBOSE1-LABEL: @scalars37func.func @scalars(%arg0: tensor<f32>, %arg1: tensor<f32>) -> (tensor<f32>) {38 // No runtime checks are required if the operands are all scalars39 // CHECK-NOT: cf.assert40 // VERBOSE1-NOT: cf.assert41 %result = tensor.empty() : tensor<f32> 42 %0 = linalg.generic {43 indexing_maps = [#map, #map, #map],44 iterator_types = []45 } ins(%arg0, %arg1 : tensor<f32>, tensor<f32>)46 outs(%result : tensor<f32>) {47 ^bb0(%gen_arg1: f32, %gen_arg2: f32, %out: f32) :48 %tmp1 = arith.addf %gen_arg1, %gen_arg2 : f3249 linalg.yield %tmp1 : f3250 } -> tensor<f32>51 return %0 : tensor<f32>52}53