1// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=10,25" | FileCheck %s -check-prefix=TILE-10n25 2// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=25,0" | FileCheck %s -check-prefix=TILE-25n0 3// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,25" | FileCheck %s -check-prefix=TILE-0n25 4 5#id_1d = affine_map<(i) -> (i)> 6#pointwise_1d_trait = { 7 args_in = 1, 8 args_out = 1, 9 indexing_maps = [#id_1d, #id_1d], 10 iterator_types = ["parallel"] 11} 12func @indexed_generic_vector(%operand: memref<50xf32>, %result: memref<50xf32>) { 13 linalg.indexed_generic #pointwise_1d_trait 14 ins(%operand :memref<50xf32>) 15 outs(%result : memref<50xf32>) { 16 ^bb0(%i: index, %operand_in: f32, %result_in: f32): 17 %i_int = index_cast %i: index to i32 18 %i_float = sitofp %i_int : i32 to f32 19 %out = addf %operand_in, %i_float : f32 20 linalg.yield %out : f32 21 } 22 return 23} 24// TILE-10n25-LABEL: func @indexed_generic_vector 25// TILE-10n25: %[[C10:.*]] = constant 10 : index 26// TILE-10n25: scf.for %[[J:.*]] = {{.*}} step %[[C10]] 27// TILE-10n25: linalg.indexed_generic 28// TILE-10n25: ^bb0(%[[I:.*]]: index, %[[IN:.*]]: f32, %[[OUT:.*]]: f32) 29// TILE-10n25: %[[NEW_I:.*]] = addi %[[I]], %[[J]] : index 30// TILE-10n25: %[[NEW_I_INT:.*]] = index_cast %[[NEW_I]] : index to i32 31// TILE-10n25: %[[NEW_I_FLOAT:.*]] = sitofp %[[NEW_I_INT]] : i32 to f32 32// TILE-10n25: %[[OUT:.*]] = addf %[[IN]], %[[NEW_I_FLOAT]] : f32 33 34// TILE-25n0-LABEL: func @indexed_generic_vector 35// TILE-25n0: %[[C25:.*]] = constant 25 : index 36// TILE-25n0: scf.for %[[J:.*]] = {{.*}} step %[[C25]] 37// TILE-25n0: linalg.indexed_generic 38// TILE-25n0: ^bb0(%[[I:.*]]: index, %[[IN:.*]]: f32, %[[OUT:.*]]: f32) 39// TILE-25n0: %[[NEW_I:.*]] = addi %[[I]], %[[J]] : index 40// TILE-25n0: %[[NEW_I_INT:.*]] = index_cast %[[NEW_I]] : index to i32 41// TILE-25n0: %[[NEW_I_FLOAT:.*]] = sitofp %[[NEW_I_INT]] : i32 to f32 42// TILE-25n0: %[[OUT:.*]] = addf %[[IN]], %[[NEW_I_FLOAT]] : f32 43 44// TILE-0n25-LABEL: func @indexed_generic_vector 45// TILE-0n25-NOT: scf.for %[[J:.*]] = {{.*}} step %[[C25]] 46// TILE-0n25: linalg.indexed_generic 47 48#combined_indices_trait = { 49 args_in = 1, 50 args_out = 1, 51 indexing_maps = [ 52 affine_map<(i, j) -> (j, i + j)>, 53 affine_map<(i, j) -> (i, j)> 54 ], 55 iterator_types = ["parallel", "parallel"] 56} 57func @indexed_generic_matrix(%operand: memref<50x100xf32>, %result: memref<50x100xf32>) { 58 linalg.indexed_generic #combined_indices_trait 59 ins(%operand : memref<50x100xf32>) 60 outs(%result : memref<50x100xf32>) { 61 ^bb0(%i: index, %j: index, %operand_in: f32, %result_in: f32): 62 %i_int = index_cast %i: index to i32 63 %i_float = sitofp %i_int : i32 to f32 64 %j_int = index_cast %j: index to i32 65 %j_float = sitofp %j_int : i32 to f32 66 %out = addf %i_float, %j_float : f32 67 linalg.yield %out : f32 68 } 69 return 70} 71// TILE-10n25-LABEL: func @indexed_generic_matrix 72// TILE-10n25-DAG: %[[C25:.*]] = constant 25 : index 73// TILE-10n25-DAG: %[[C10:.*]] = constant 10 : index 74// TILE-10n25: scf.for %[[K:.*]] = {{.*}} step %[[C10]] 75// TILE-10n25: scf.for %[[L:.*]] = {{.*}} step %[[C25]] 76// TILE-10n25: linalg.indexed_generic 77// TILE-10n25: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index, %[[IN:.*]]: f32, %[[OUT:.*]]: f32): 78// TILE-10n25: %[[NEW_I:.*]] = addi %[[I]], %[[K]] : index 79// TILE-10n25: %[[NEW_J:.*]] = addi %[[J]], %[[L]] : index 80// TILE-10n25: %[[NEW_INT_I:.*]] = index_cast %[[NEW_I]] : index to i32 81// TILE-10n25: %[[NEW_FLOAT_I:.*]] = sitofp %[[NEW_INT_I]] : i32 to f32 82// TILE-10n25: %[[NEW_INT_J:.*]] = index_cast %[[NEW_J]] : index to i32 83// TILE-10n25: %[[NEW_FLOAT_J:.*]] = sitofp %[[NEW_INT_J]] : i32 to f32 84// TILE-10n25: %[[OUT:.*]] = addf %[[NEW_FLOAT_I]], %[[NEW_FLOAT_J]] : f32 85 86// TILE-25n0-LABEL: func @indexed_generic_matrix 87// TILE-25n0: %[[C25:.*]] = constant 25 : index 88// TILE-25n0: scf.for %[[L:.*]] = {{.*}} step %[[C25]] 89// TILE-25n0: linalg.indexed_generic 90// TILE-25n0: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index, %[[IN:.*]]: f32, %[[OUT:.*]]: f32): 91// TILE-25n0: %[[NEW_I:.*]] = addi %[[I]], %[[L]] : index 92// TILE-25n0: %[[NEW_INT_I:.*]] = index_cast %[[NEW_I]] : index to i32 93// TILE-25n0: %[[NEW_FLOAT_I:.*]] = sitofp %[[NEW_INT_I]] : i32 to f32 94// TILE-25n0: %[[INT_J:.*]] = index_cast %[[J]] : index to i32 95// TILE-25n0: %[[FLOAT_J:.*]] = sitofp %[[INT_J]] : i32 to f32 96// TILE-25n0: %[[OUT:.*]] = addf %[[NEW_FLOAT_I]], %[[FLOAT_J]] : f32 97 98// TILE-0n25-LABEL: func @indexed_generic_matrix 99// TILE-0n25: %[[C25:.*]] = constant 25 : index 100// TILE-0n25: scf.for %[[L:.*]] = {{.*}} step %[[C25]] 101// TILE-0n25: linalg.indexed_generic 102// TILE-0n25: ^bb0(%[[I:.*]]: index, %[[J:.*]]: index, %[[IN:.*]]: f32, %[[OUT:.*]]: f32): 103// TILE-0n25: %[[NEW_J:.*]] = addi %[[J]], %[[L]] : index 104// TILE-0n25: %[[INT_I:.*]] = index_cast %[[I]] : index to i32 105// TILE-0n25: %[[FLOAT_I:.*]] = sitofp %[[INT_I]] : i32 to f32 106// TILE-0n25: %[[NEW_INT_J:.*]] = index_cast %[[NEW_J]] : index to i32 107// TILE-0n25: %[[NEW_FLOAT_J:.*]] = sitofp %[[NEW_INT_J]] : i32 to f32 108// TILE-0n25: %[[OUT:.*]] = addf %[[FLOAT_I]], %[[NEW_FLOAT_J]] : f32 109