|
45 | 45 | #hal.pipeline.binding<storage_buffer> |
46 | 46 | ]> |
47 | 47 |
|
48 | | -func.func @matmul_lowering_ukernel_provider() attributes {hal.executable.target = #executable_target_rocm_hsaco_fb} { |
| 48 | +func.func @matmul_f16_f16_f32_large_lowering_ukernel_provider() attributes {hal.executable.target = #executable_target_rocm_hsaco_fb} { |
49 | 49 | %c0 = arith.constant 0 : index |
| 50 | + // M, N, K are dynamic. |
50 | 51 | %M = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(0) : index |
51 | 52 | %N = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(1) : index |
52 | 53 | %K = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(2) : index |
@@ -75,7 +76,168 @@ func.func @matmul_lowering_ukernel_provider() attributes {hal.executable.target |
75 | 76 | -> !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x?xf32, #encoding_result>>{%M, %N} |
76 | 77 | return |
77 | 78 | } |
78 | | -// CHECK-LABEL: matmul_lowering_ukernel_provider |
| 79 | +// CHECK-LABEL: matmul_f16_f16_f32_large_lowering_ukernel_provider |
79 | 80 | // CHECK: iree_codegen.inner_tiled |
80 | 81 | // CHECK-SAME: iterator_types = [#linalg.iterator_type<parallel>, #linalg.iterator_type<parallel>, #linalg.iterator_type<reduction>] |
81 | 82 | // CHECK-SAME: kind = #iree_gpu.data_tiled_mma_layout<intrinsic = MFMA_F32_16x16x16_F16, intrinsics_m = 8, subgroups_m = 2, intrinsics_n = 4, subgroups_n = 4> |
| 83 | + |
| 84 | +// ----- |
| 85 | + |
| 86 | +#executable_target_rocm_hsaco_fb = #hal.executable.target<"rocm", "rocm-hsaco-fb", { |
| 87 | + abi = "hip", |
| 88 | + iree.encoding.resolver = #iree_gpu.gpu_encoding_resolver<>, |
| 89 | + iree_codegen.target_info = #iree_gpu.target< |
| 90 | + arch = "gfx942", |
| 91 | + features = "", |
| 92 | + wgp = <compute = fp64|fp32|fp16|int64|int32|int16|int8, |
| 93 | + storage = b64|b32|b16|b8, |
| 94 | + subgroup = shuffle|arithmetic, |
| 95 | + dot = dp4xi8toi32, |
| 96 | + mma = [<MFMA_F32_16x16x16_BF16>, <MFMA_F32_32x32x8_BF16>, <MFMA_F32_16x16x32_F8E5M2FNUZ>, |
| 97 | + <MFMA_F32_16x16x32_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_16x16x32_F8E4M3FNUZ>, |
| 98 | + <MFMA_F32_16x16x32_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_F32_32x32x16_F8E5M2FNUZ>, |
| 99 | + <MFMA_F32_32x32x16_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_32x32x16_F8E4M3FNUZ>, |
| 100 | + <MFMA_F32_32x32x16_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_I32_16x16x32_I8>, |
| 101 | + <MFMA_I32_32x32x16_I8>, <MFMA_F64_16x16x4_F64>, <MFMA_F32_16x16x4_F32>, |
| 102 | + <MFMA_F32_16x16x16_F16>, <MFMA_F32_32x32x8_F16> |
| 103 | + ], |
| 104 | + subgroup_size_choices = [64], |
| 105 | + max_workgroup_sizes = [1024, 1024, 1024], |
| 106 | + max_thread_count_per_workgroup = 1024, |
| 107 | + max_workgroup_memory_bytes = 65536, |
| 108 | + max_workgroup_counts = [2147483647, 2147483647, 2147483647], |
| 109 | + max_load_instruction_bits = 128, |
| 110 | + simds_per_wgp = 4, |
| 111 | + vgpr_space_bits = 16384> |
| 112 | + >, |
| 113 | + iree_codegen.ukernel_provider = #rocm.tensor_ukernel_provider, |
| 114 | + ukernels = "none" |
| 115 | +}> |
| 116 | + |
| 117 | +#map = affine_map<(d0, d1, d2) -> (d0, d2)> |
| 118 | +#map1 = affine_map<(d0, d1, d2) -> (d2, d1)> |
| 119 | +#map2 = affine_map<(d0, d1, d2) -> (d0, d1)> |
| 120 | +#encoding_lhs = #iree_encoding.encoding<operand_index = 0, op_type = matmul, element_types = [f8E4M3FNUZ, f8E4M3FNUZ, f32], user_indexing_maps = [#map, #map1, #map2], iteration_sizes = [?, ?, ?]> |
| 121 | +#encoding_rhs = #iree_encoding.encoding<operand_index = 1, op_type = matmul, element_types = [f8E4M3FNUZ, f8E4M3FNUZ, f32], user_indexing_maps = [#map, #map1, #map2], iteration_sizes = [?, ?, ?]> |
| 122 | +#encoding_result = #iree_encoding.encoding<operand_index = 2, op_type = matmul, element_types = [f8E4M3FNUZ, f8E4M3FNUZ, f32], user_indexing_maps = [#map, #map1, #map2], iteration_sizes = [?, ?, ?]> |
| 123 | +#pipeline_layout_3 = #hal.pipeline.layout<constants = 3, bindings = [ |
| 124 | + #hal.pipeline.binding<storage_buffer>, |
| 125 | + #hal.pipeline.binding<storage_buffer>, |
| 126 | + #hal.pipeline.binding<storage_buffer> |
| 127 | +]> |
| 128 | + |
| 129 | +func.func @matmul_f8_f8_f32_medium_lowering_ukernel_provider() attributes {hal.executable.target = #executable_target_rocm_hsaco_fb} { |
| 130 | + %c0 = arith.constant 0 : index |
| 131 | + // M, N, K are dynamic. |
| 132 | + %M = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(0) : index |
| 133 | + %N = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(1) : index |
| 134 | + %K = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(2) : index |
| 135 | + %0 = hal.interface.binding.subspan layout(#pipeline_layout_3) binding(0) alignment(64) offset(%c0) |
| 136 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x?xf8E4M3FNUZ, #encoding_lhs>>{%M, %K} |
| 137 | + %1 = hal.interface.binding.subspan layout(#pipeline_layout_3) binding(1) alignment(64) offset(%c0) |
| 138 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x?xf8E4M3FNUZ, #encoding_rhs>>{%K, %N} |
| 139 | + %2 = hal.interface.binding.subspan layout(#pipeline_layout_3) binding(2) alignment(64) offset(%c0) |
| 140 | + : !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x?xf32, #encoding_result>>{%M, %N} |
| 141 | + %3 = iree_tensor_ext.dispatch.tensor.load %0, offsets = [0, 0], sizes = [%M, %K], strides = [1, 1] |
| 142 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x?xf8E4M3FNUZ, #encoding_lhs>>{%M, %K} |
| 143 | + -> tensor<?x?xf8E4M3FNUZ, #encoding_lhs> |
| 144 | + %4 = iree_tensor_ext.dispatch.tensor.load %1, offsets = [0, 0], sizes = [%K, %N], strides = [1, 1] |
| 145 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x?xf8E4M3FNUZ, #encoding_rhs>>{%K, %N} |
| 146 | + -> tensor<?x?xf8E4M3FNUZ, #encoding_rhs> |
| 147 | + %5 = iree_tensor_ext.dispatch.tensor.load %2, offsets = [0, 0], sizes = [%M, %N], strides = [1, 1] |
| 148 | + : !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x?xf32, #encoding_result>>{%M, %N} |
| 149 | + -> tensor<?x?xf32, #encoding_result> |
| 150 | + %6 = linalg.matmul |
| 151 | + ins(%3, %4 : tensor<?x?xf8E4M3FNUZ, #encoding_lhs>, |
| 152 | + tensor<?x?xf8E4M3FNUZ, #encoding_rhs>) |
| 153 | + outs(%5 : tensor<?x?xf32, #encoding_result>) |
| 154 | + -> tensor<?x?xf32, #encoding_result> |
| 155 | + iree_tensor_ext.dispatch.tensor.store %6, %2, offsets = [0, 0], sizes = [%M, %N], strides = [1, 1] |
| 156 | + : tensor<?x?xf32, #encoding_result> |
| 157 | + -> !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x?xf32, #encoding_result>>{%M, %N} |
| 158 | + return |
| 159 | +} |
| 160 | +// CHECK-LABEL: matmul_f8_f8_f32_medium_lowering_ukernel_provider |
| 161 | +// CHECK: iree_codegen.inner_tiled |
| 162 | +// CHECK-SAME: iterator_types = [#linalg.iterator_type<parallel>, #linalg.iterator_type<parallel>, #linalg.iterator_type<reduction>] |
| 163 | +// CHECK-SAME: kind = #iree_gpu.data_tiled_mma_layout<intrinsic = MFMA_F32_16x16x32_F8E4M3FNUZ, intrinsics_m = 8, intrinsics_n = 2, subgroups_n = 8, intrinsics_k = 2> |
| 164 | + |
| 165 | +// ----- |
| 166 | + |
| 167 | +#executable_target_rocm_hsaco_fb = #hal.executable.target<"rocm", "rocm-hsaco-fb", { |
| 168 | + abi = "hip", |
| 169 | + iree.encoding.resolver = #iree_gpu.gpu_encoding_resolver<>, |
| 170 | + iree_codegen.target_info = #iree_gpu.target< |
| 171 | + arch = "gfx942", |
| 172 | + features = "", |
| 173 | + wgp = <compute = fp64|fp32|fp16|int64|int32|int16|int8, |
| 174 | + storage = b64|b32|b16|b8, |
| 175 | + subgroup = shuffle|arithmetic, |
| 176 | + dot = dp4xi8toi32, |
| 177 | + mma = [<MFMA_F32_16x16x16_BF16>, <MFMA_F32_32x32x8_BF16>, <MFMA_F32_16x16x32_F8E5M2FNUZ>, |
| 178 | + <MFMA_F32_16x16x32_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_16x16x32_F8E4M3FNUZ>, |
| 179 | + <MFMA_F32_16x16x32_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_F32_32x32x16_F8E5M2FNUZ>, |
| 180 | + <MFMA_F32_32x32x16_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_32x32x16_F8E4M3FNUZ>, |
| 181 | + <MFMA_F32_32x32x16_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_I32_16x16x32_I8>, |
| 182 | + <MFMA_I32_32x32x16_I8>, <MFMA_F64_16x16x4_F64>, <MFMA_F32_16x16x4_F32>, |
| 183 | + <MFMA_F32_16x16x16_F16>, <MFMA_F32_32x32x8_F16> |
| 184 | + ], |
| 185 | + subgroup_size_choices = [64], |
| 186 | + max_workgroup_sizes = [1024, 1024, 1024], |
| 187 | + max_thread_count_per_workgroup = 1024, |
| 188 | + max_workgroup_memory_bytes = 65536, |
| 189 | + max_workgroup_counts = [2147483647, 2147483647, 2147483647], |
| 190 | + max_load_instruction_bits = 128, |
| 191 | + simds_per_wgp = 4, |
| 192 | + vgpr_space_bits = 16384> |
| 193 | + >, |
| 194 | + iree_codegen.ukernel_provider = #rocm.tensor_ukernel_provider, |
| 195 | + ukernels = "none" |
| 196 | +}> |
| 197 | + |
| 198 | +#map = affine_map<(d0, d1, d2) -> (d0, d2)> |
| 199 | +#map1 = affine_map<(d0, d1, d2) -> (d2, d1)> |
| 200 | +#map2 = affine_map<(d0, d1, d2) -> (d0, d1)> |
| 201 | +#encoding_lhs = #iree_encoding.encoding<operand_index = 0, op_type = matmul, element_types = [f8E4M3FNUZ, f8E4M3FNUZ, f32], user_indexing_maps = [#map, #map1, #map2], iteration_sizes = [?, 2048, ?]> |
| 202 | +#encoding_rhs = #iree_encoding.encoding<operand_index = 1, op_type = matmul, element_types = [f8E4M3FNUZ, f8E4M3FNUZ, f32], user_indexing_maps = [#map, #map1, #map2], iteration_sizes = [?, 2048, ?]> |
| 203 | +#encoding_result = #iree_encoding.encoding<operand_index = 2, op_type = matmul, element_types = [f8E4M3FNUZ, f8E4M3FNUZ, f32], user_indexing_maps = [#map, #map1, #map2], iteration_sizes = [?, 2048, ?]> |
| 204 | +#pipeline_layout_3 = #hal.pipeline.layout<constants = 2, bindings = [ |
| 205 | + #hal.pipeline.binding<storage_buffer>, |
| 206 | + #hal.pipeline.binding<storage_buffer>, |
| 207 | + #hal.pipeline.binding<storage_buffer> |
| 208 | +]> |
| 209 | + |
| 210 | +func.func @matmul_f8_f8_f32_large_lowering_ukernel_provider() attributes {hal.executable.target = #executable_target_rocm_hsaco_fb} { |
| 211 | + %c0 = arith.constant 0 : index |
| 212 | + // M, K are dynamic, and N is static as 2048. |
| 213 | + %M = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(0) : index |
| 214 | + %K = hal.interface.constant.load layout(#pipeline_layout_3) ordinal(1) : index |
| 215 | + %0 = hal.interface.binding.subspan layout(#pipeline_layout_3) binding(0) alignment(64) offset(%c0) |
| 216 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x?xf8E4M3FNUZ, #encoding_lhs>>{%M, %K} |
| 217 | + %1 = hal.interface.binding.subspan layout(#pipeline_layout_3) binding(1) alignment(64) offset(%c0) |
| 218 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x2048xf8E4M3FNUZ, #encoding_rhs>>{%K} |
| 219 | + %2 = hal.interface.binding.subspan layout(#pipeline_layout_3) binding(2) alignment(64) offset(%c0) |
| 220 | + : !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x2048xf32, #encoding_result>>{%M} |
| 221 | + %3 = iree_tensor_ext.dispatch.tensor.load %0, offsets = [0, 0], sizes = [%M, %K], strides = [1, 1] |
| 222 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x?xf8E4M3FNUZ, #encoding_lhs>>{%M, %K} |
| 223 | + -> tensor<?x?xf8E4M3FNUZ, #encoding_lhs> |
| 224 | + %4 = iree_tensor_ext.dispatch.tensor.load %1, offsets = [0, 0], sizes = [%K, 2048], strides = [1, 1] |
| 225 | + : !iree_tensor_ext.dispatch.tensor<readonly:tensor<?x2048xf8E4M3FNUZ, #encoding_rhs>>{%K} |
| 226 | + -> tensor<?x2048xf8E4M3FNUZ, #encoding_rhs> |
| 227 | + %5 = iree_tensor_ext.dispatch.tensor.load %2, offsets = [0, 0], sizes = [%M, 2048], strides = [1, 1] |
| 228 | + : !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x2048xf32, #encoding_result>>{%M} |
| 229 | + -> tensor<?x2048xf32, #encoding_result> |
| 230 | + %6 = linalg.matmul |
| 231 | + ins(%3, %4 : tensor<?x?xf8E4M3FNUZ, #encoding_lhs>, |
| 232 | + tensor<?x2048xf8E4M3FNUZ, #encoding_rhs>) |
| 233 | + outs(%5 : tensor<?x2048xf32, #encoding_result>) |
| 234 | + -> tensor<?x2048xf32, #encoding_result> |
| 235 | + iree_tensor_ext.dispatch.tensor.store %6, %2, offsets = [0, 0], sizes = [%M, 2048], strides = [1, 1] |
| 236 | + : tensor<?x2048xf32, #encoding_result> |
| 237 | + -> !iree_tensor_ext.dispatch.tensor<readwrite:tensor<?x2048xf32, #encoding_result>>{%M} |
| 238 | + return |
| 239 | +} |
| 240 | +// CHECK-LABEL: matmul_f8_f8_f32_large_lowering_ukernel_provider |
| 241 | +// CHECK: iree_codegen.inner_tiled |
| 242 | +// CHECK-SAME: iterator_types = [#linalg.iterator_type<parallel>, #linalg.iterator_type<parallel>, #linalg.iterator_type<reduction>] |
| 243 | +// CHECK-SAME: kind = #iree_gpu.data_tiled_mma_layout<intrinsic = MFMA_F32_16x16x32_F8E4M3FNUZ, intrinsics_m = 8, subgroups_m = 2, intrinsics_n = 4, subgroups_n = 4> |
0 commit comments