Skip to content

Consumer fusion not happening in CombineLayoutTransformationPass #21635

Open

Description

@nirvedhmeshram

For this IR

func.func @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async_dispatch_0_matmul_like_5520x1024x2016_bf16xbf16xf32() attributes {translation_info = #iree_codegen.translation_info<pipeline = LLVMGPUTileAndFuse workgroup_size = [256, 1, 1] subgroup_size = 64, {gpu_pipeline_options = #iree_gpu.pipeline_options<prefetch_shared_memory = true, no_reduce_shared_memory_bank_conflicts = false, use_igemm_convolution = false>}>} {
  %c256 = arith.constant 256 : index
  %c512 = arith.constant 512 : index
  %c2 = arith.constant 2 : index
  %c126 = arith.constant 126 : index
  %cst = arith.constant 0.000000e+00 : bf16
  %cst_0 = arith.constant 0.000000e+00 : f32
  %c0 = arith.constant 0 : index
  %0 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(0) alignment(64) offset(%c0) flags("ReadOnly|Indirect") {iree_gpu.use_rocdl_buffer_instructions} : !iree_tensor_ext.dispatch.tensor<readonly:tensor<5520x2016xbf16>>
  %1 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(1) alignment(64) offset(%c0) flags("ReadOnly|Indirect") {iree_gpu.use_rocdl_buffer_instructions} : !iree_tensor_ext.dispatch.tensor<readonly:tensor<1024x2016xbf16>>
  %2 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(2) alignment(64) offset(%c0) flags(Indirect) {iree_gpu.use_rocdl_buffer_instructions} : !iree_tensor_ext.dispatch.tensor<writeonly:tensor<5520x1024xbf16>>
  %3 = iree_tensor_ext.dispatch.tensor.load %0, offsets = [0, 0], sizes = [5520, 2016], strides = [1, 1] : !iree_tensor_ext.dispatch.tensor<readonly:tensor<5520x2016xbf16>> -> tensor<5520x2016xbf16>
  %4 = iree_tensor_ext.dispatch.tensor.load %1, offsets = [0, 0], sizes = [1024, 2016], strides = [1, 1] : !iree_tensor_ext.dispatch.tensor<readonly:tensor<1024x2016xbf16>> -> tensor<1024x2016xbf16>
  %5 = tensor.empty() : tensor<5520x1024xbf16>
  %6 = scf.forall (%arg0, %arg1) in (44, 8) shared_outs(%arg2 = %5) -> (tensor<5520x1024xbf16>) {
    %7 = affine.apply affine_map<(d0) -> (d0 * 128)>(%arg1)
    %8 = affine.apply affine_map<(d0) -> (d0 * 128)>(%arg0)
    %9 = affine.min affine_map<(d0) -> (d0 * -128 + 5520, 128)>(%arg0)
    %extracted_slice = tensor.extract_slice %arg2[%8, %7] [%9, 128] [1, 1] : tensor<5520x1024xbf16> to tensor<?x128xbf16>
    %10 = affine.min affine_map<(d0) -> (d0 * -128 + 5520, 0, 128)>(%arg0)
    %11 = affine.min affine_map<(d0, d1) -> (128, d0 - d1)>(%9, %10)
    %12 = bufferization.alloc_tensor() {memory_space = #gpu.address_space<workgroup>} : tensor<128x32xbf16>
    %13 = bufferization.alloc_tensor() {memory_space = #gpu.address_space<workgroup>} : tensor<128x32xbf16>
    %14 = tensor.empty() : tensor<8x16x8x16xf32>
    %15 = scf.forall (%arg3, %arg4, %arg5) in (2, 2, 64) shared_outs(%arg6 = %14) -> (tensor<8x16x8x16xf32>) {
      %17:3 = affine.delinearize_index %arg5 into (4, 16) : index, index, index
      %18 = affine.linearize_index disjoint [%17#1, %c0] by (4, 4) : index
      %19 = tensor.empty() : tensor<4x4x4x1xf32>
      %20 = linalg.fill ins(%cst_0 : f32) outs(%19 : tensor<4x4x4x1xf32>) -> tensor<4x4x4x1xf32>
      %21 = scf.for %arg7 = %c0 to %c126 step %c2 iter_args(%arg8 = %20) -> (tensor<4x4x4x1xf32>) {
        %26 = iree_gpu.barrier_region ins(%13 : tensor<128x32xbf16>) {
        ^bb0(%arg9: tensor<128x32xbf16>):
          %32 = scf.for %arg10 = %c0 to %c512 step %c256 iter_args(%arg11 = %arg9) -> (tensor<128x32xbf16>) {
            %33 = affine.apply affine_map<(d0, d1, d2, d3) -> (d0 + d1 + d2 * 128 + d3 * 64)>(%arg10, %arg5, %arg3, %arg4)
            %34:2 = affine.delinearize_index %33 into (128, 4) : index, index
            %35 = affine.apply affine_map<(d0) -> (d0 * 8)>(%34#1)
            %extracted_slice_8 = tensor.extract_slice %arg11[%34#0, %35] [1, 8] [1, 1] : tensor<128x32xbf16> to tensor<1x8xbf16>
            %36 = affine.min affine_map<(d0, d1, d2) -> (128, d1 - d2, d0)>(%34#0, %9, %10)
            %37 = affine.min affine_map<(d0, d1) -> (1, d0 - d1)>(%11, %36)
            %38 = affine.apply affine_map<(d0) -> (-d0 + 1)>(%37)
            %39 = affine.apply affine_map<(d0)[s0, s1] -> (d0 * 128 + s0 + s1)>(%arg0)[%36, %10]
            %40 = affine.apply affine_map<(d0, d1) -> (d0 * 16 + d1 * 8)>(%arg7, %34#1)
            %extracted_slice_9 = tensor.extract_slice %3[%39, %40] [%37, 8] [1, 1] : tensor<5520x2016xbf16> to tensor<?x8xbf16>
            %padded = tensor.pad %extracted_slice_9 low[0, 0] high[%38, 0] {
            ^bb0(%arg12: index, %arg13: index):
              tensor.yield %cst : bf16
            } : tensor<?x8xbf16> to tensor<1x8xbf16>
            %41 = linalg.copy {lowering_config = #iree_gpu.derived_thread_config} ins(%padded : tensor<1x8xbf16>) outs(%extracted_slice_8 : tensor<1x8xbf16>) -> tensor<1x8xbf16>
            %inserted_slice = tensor.insert_slice %41 into %arg11[%34#0, %35] [1, 8] [1, 1] : tensor<1x8xbf16> into tensor<128x32xbf16>
            scf.yield %inserted_slice : tensor<128x32xbf16>
          } {unroll_loop}
          iree_gpu.yield %32 : tensor<128x32xbf16>
        } : tensor<128x32xbf16>
        %27 = iree_gpu.barrier_region ins(%12 : tensor<128x32xbf16>) {
        ^bb0(%arg9: tensor<128x32xbf16>):
          %32 = scf.for %arg10 = %c0 to %c512 step %c256 iter_args(%arg11 = %arg9) -> (tensor<128x32xbf16>) {
            %33 = affine.apply affine_map<(d0, d1, d2, d3) -> (d0 + d1 + d2 * 128 + d3 * 64)>(%arg10, %arg5, %arg3, %arg4)
            %34:2 = affine.delinearize_index %33 into (128, 4) : index, index
            %35 = affine.apply affine_map<(d0) -> (d0 * 8)>(%34#1)
            %extracted_slice_8 = tensor.extract_slice %arg11[%34#0, %35] [1, 8] [1, 1] : tensor<128x32xbf16> to tensor<1x8xbf16>
            %36 = affine.apply affine_map<(d0)[s0] -> (d0 * 128 + s0)>(%arg1)[%34#0]
            %37 = affine.apply affine_map<(d0, d1) -> (d0 * 16 + d1 * 8)>(%arg7, %34#1)
            %extracted_slice_9 = tensor.extract_slice %4[%36, %37] [1, 8] [1, 1] : tensor<1024x2016xbf16> to tensor<1x8xbf16>
            %38 = linalg.copy {lowering_config = #iree_gpu.derived_thread_config} ins(%extracted_slice_9 : tensor<1x8xbf16>) outs(%extracted_slice_8 : tensor<1x8xbf16>) -> tensor<1x8xbf16>
            %inserted_slice = tensor.insert_slice %38 into %arg11[%34#0, %35] [1, 8] [1, 1] : tensor<1x8xbf16> into tensor<128x32xbf16>
            scf.yield %inserted_slice : tensor<128x32xbf16>
          } {unroll_loop}
          iree_gpu.yield %32 : tensor<128x32xbf16>
        } : tensor<128x32xbf16>
        %28 = affine.apply affine_map<(d0) -> (d0 * 4)>(%arg4)
        %29 = affine.apply affine_map<(d0) -> (d0 * 4)>(%arg3)
        %expanded = tensor.expand_shape %27 [[0, 1], [2, 3]] output_shape [8, 16, 2, 16] : tensor<128x32xbf16> into tensor<8x16x2x16xbf16>
        %extracted_slice_3 = tensor.extract_slice %expanded[%28, %17#2, 0, %18] [4, 1, 2, 4] [1, 1, 1, 1] : tensor<8x16x2x16xbf16> to tensor<4x1x2x4xbf16>
        %expanded_4 = tensor.expand_shape %26 [[0, 1], [2, 3]] output_shape [8, 16, 2, 16] : tensor<128x32xbf16> into tensor<8x16x2x16xbf16>
        %extracted_slice_5 = tensor.extract_slice %expanded_4[%29, %17#2, 0, %18] [4, 1, 2, 4] [1, 1, 1, 1] : tensor<8x16x2x16xbf16> to tensor<4x1x2x4xbf16>
        %30 = tensor.empty() : tensor<4x2x1x4xbf16>
        %transposed_6 = linalg.transpose ins(%extracted_slice_5 : tensor<4x1x2x4xbf16>) outs(%30 : tensor<4x2x1x4xbf16>) permutation = [0, 2, 1, 3] 
        %transposed_7 = linalg.transpose ins(%extracted_slice_3 : tensor<4x1x2x4xbf16>) outs(%30 : tensor<4x2x1x4xbf16>) permutation = [0, 2, 1, 3] 
        %31 = iree_codegen.inner_tiled ins(%transposed_6, %transposed_7) outs(%arg8) {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d1, d2)>, affine_map<(d0, d1, d2) -> (d0, d1)>], iterator_types = [#linalg.iterator_type<parallel>, #linalg.iterator_type<parallel>, #linalg.iterator_type<reduction>], kind = #iree_gpu.mma_layout<MFMA_F32_16x16x16_BF16>, lowering_config = #iree_gpu.lowering_config<{mma_kind = #iree_gpu.mma_layout<MFMA_F32_16x16x16_BF16>, padding = [128, 128, 32], promote_operands = [0, 1], reduction = [0, 0, 2], subgroup = [4, 4, 0], workgroup = [128, 128, 0]}>} : tensor<4x2x1x4xbf16>, tensor<4x2x1x4xbf16> into tensor<4x4x4x1xf32>
        scf.yield %31 : tensor<4x4x4x1xf32>
      }
      %22 = tensor.empty() : tensor<4x4x4x1xf32>
      %transposed = linalg.transpose ins(%21 : tensor<4x4x4x1xf32>) outs(%22 : tensor<4x4x4x1xf32>) permutation = [0, 2, 1, 3] 
      %23 = affine.apply affine_map<(d0) -> (d0 * 4)>(%arg3)
      %24 = affine.apply affine_map<(d0) -> (d0 * 4)>(%arg4)
      %extracted_slice_2 = tensor.extract_slice %arg6[%23, %18, %24, %17#2] [4, 4, 4, 1] [1, 1, 1, 1] : tensor<8x16x8x16xf32> to tensor<4x4x4x1xf32>
      %25 = linalg.copy ins(%transposed : tensor<4x4x4x1xf32>) outs(%extracted_slice_2 : tensor<4x4x4x1xf32>) -> tensor<4x4x4x1xf32>
      scf.forall.in_parallel {
        tensor.parallel_insert_slice %25 into %arg6[%23, %18, %24, %17#2] [4, 4, 4, 1] [1, 1, 1, 1] : tensor<4x4x4x1xf32> into tensor<8x16x8x16xf32>
      }
    } {mapping = [#gpu.thread<linear_dim_2>, #gpu.thread<linear_dim_1>, #gpu.thread<linear_dim_0>]}
    %collapsed = tensor.collapse_shape %15 [[0, 1], [2, 3]] : tensor<8x16x8x16xf32> into tensor<128x128xf32>
    %extracted_slice_1 = tensor.extract_slice %collapsed[0, 0] [%9, 128] [1, 1] : tensor<128x128xf32> to tensor<?x128xf32>
    %16 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>], iterator_types = ["parallel", "parallel"]} ins(%extracted_slice_1 : tensor<?x128xf32>) outs(%extracted_slice : tensor<?x128xbf16>) {
    ^bb0(%in: f32, %out: bf16):
      %17 = arith.truncf %in : f32 to bf16
      linalg.yield %17 : bf16
    } -> tensor<?x128xbf16>
    scf.forall.in_parallel {
      tensor.parallel_insert_slice %16 into %arg2[%8, %7] [%9, 128] [1, 1] : tensor<?x128xbf16> into tensor<5520x1024xbf16>
    }
  } {mapping = [#iree_codegen.workgroup_mapping<y>, #iree_codegen.workgroup_mapping<x>]}
  iree_tensor_ext.dispatch.tensor.store %6, %2, offsets = [0, 0], sizes = [5520, 1024], strides = [1, 1] : tensor<5520x1024xbf16> -> !iree_tensor_ext.dispatch.tensor<writeonly:tensor<5520x1024xbf16>>
  return
}

Run

iree-opt --pass-pipeline="builtin.module(func.func(iree-codegen-combine-layout-transformation))" test.mlir

The elementwise generic is not fusing into the thread loop. This issue is causing the no c promotion path for unaligned GEMMs/Convs to fail as it creates a third allocation.

Activity

  1. nirvedhmeshram commented on Aug 8, 2025

    @nirvedhmeshram
    ContributorAuthor

    This revert had no effect on this a005576

  2. nirvedhmeshram commented on Aug 8, 2025

    @nirvedhmeshram
    ContributorAuthor

    Here are also steps for a full repro
    Input IR

    module @module attributes {stream.affinity.default = #hal.device.affinity<@__device_0>} {
      util.global private @__device_0 = #hal.device.target<"hip", [#hal.executable.target<"rocm", "rocm-hsaco-fb", {abi = "hip", iree.gpu.target = #iree_gpu.target<arch = "gfx942", features = "", wgp = <compute =  fp64|fp32|fp16|int64|int32|int16|int8, storage =  b64|b32|b16|b8, subgroup =  shuffle|arithmetic, dot =  dp4xi8toi32, mma = [<MFMA_F32_16x16x16_BF16>, <MFMA_F32_32x32x8_BF16>, <MFMA_F32_16x16x32_F8E5M2FNUZ>, <MFMA_F32_16x16x32_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_16x16x32_F8E4M3FNUZ>, <MFMA_F32_16x16x32_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_F32_32x32x16_F8E5M2FNUZ>, <MFMA_F32_32x32x16_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_32x32x16_F8E4M3FNUZ>, <MFMA_F32_32x32x16_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_I32_16x16x32_I8>, <MFMA_I32_32x32x16_I8>, <MFMA_F64_16x16x4_F64>, <MFMA_F32_16x16x4_F32>, <MFMA_F32_16x16x16_F16>, <MFMA_F32_32x32x8_F16>], scaled_mma = [], subgroup_size_choices = [64], max_workgroup_sizes = [1024, 1024, 1024], max_thread_count_per_workgroup = 1024, max_workgroup_memory_bytes = 65536, max_workgroup_counts = [2147483647, 2147483647, 2147483647], max_load_instruction_bits = 128, simds_per_wgp = 4, vgpr_space_bits = 16384>>, iree_codegen.default_tuning_spec = #rocm.builtin.tuning_module<"iree_default_tuning_spec_gfx942.mlir">, ukernels = "none"}>]> : !hal.device
      hal.executable private @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async_dispatch_0 {
        hal.executable.variant public @rocm_hsaco_fb target(<"rocm", "rocm-hsaco-fb", {abi = "hip", iree.gpu.target = #iree_gpu.target<arch = "gfx942", features = "", wgp = <compute =  fp64|fp32|fp16|int64|int32|int16|int8, storage =  b64|b32|b16|b8, subgroup =  shuffle|arithmetic, dot =  dp4xi8toi32, mma = [<MFMA_F32_16x16x16_BF16>, <MFMA_F32_32x32x8_BF16>, <MFMA_F32_16x16x32_F8E5M2FNUZ>, <MFMA_F32_16x16x32_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_16x16x32_F8E4M3FNUZ>, <MFMA_F32_16x16x32_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_F32_32x32x16_F8E5M2FNUZ>, <MFMA_F32_32x32x16_F8E5M2FNUZ_F8E4M3FNUZ>, <MFMA_F32_32x32x16_F8E4M3FNUZ>, <MFMA_F32_32x32x16_F8E4M3FNUZ_F8E5M2FNUZ>, <MFMA_I32_16x16x32_I8>, <MFMA_I32_32x32x16_I8>, <MFMA_F64_16x16x4_F64>, <MFMA_F32_16x16x4_F32>, <MFMA_F32_16x16x16_F16>, <MFMA_F32_32x32x8_F16>], scaled_mma = [], subgroup_size_choices = [64], max_workgroup_sizes = [1024, 1024, 1024], max_thread_count_per_workgroup = 1024, max_workgroup_memory_bytes = 65536, max_workgroup_counts = [2147483647, 2147483647, 2147483647], max_load_instruction_bits = 128, simds_per_wgp = 4, vgpr_space_bits = 16384>>, iree_codegen.default_tuning_spec = #rocm.builtin.tuning_module<"iree_default_tuning_spec_gfx942.mlir">, ukernels = "none"}>) {
          hal.executable.export public @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async_dispatch_0_matmul_like_5520x1024x2016_bf16xbf16xf32 ordinal(0) layout(#hal.pipeline.layout<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) count(%arg0: !hal.device) -> (index, index, index) {
            %x, %y, %z = iree_tensor_ext.dispatch.workgroup_count_from_slice
            hal.return %x, %y, %z : index, index, index
          }
          builtin.module {
            func.func @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async_dispatch_0_matmul_like_5520x1024x2016_bf16xbf16xf32() attributes {translation_info = #iree_codegen.translation_info<pipeline = LLVMGPUTileAndFuse workgroup_size = [256, 1, 1] subgroup_size = 64, {gpu_pipeline_options = #iree_gpu.pipeline_options<prefetch_shared_memory = true, no_reduce_shared_memory_bank_conflicts = false, use_igemm_convolution = false>}>} {
              %cst = arith.constant 0.000000e+00 : f32
              %c0 = arith.constant 0 : index
              %0 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(0) alignment(64) offset(%c0) flags("ReadOnly|Indirect") {iree_gpu.use_rocdl_buffer_instructions} : !iree_tensor_ext.dispatch.tensor<readonly:tensor<5520x2016xbf16>>
              %1 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(1) alignment(64) offset(%c0) flags("ReadOnly|Indirect") {iree_gpu.use_rocdl_buffer_instructions} : !iree_tensor_ext.dispatch.tensor<readonly:tensor<1024x2016xbf16>>
              %2 = hal.interface.binding.subspan layout(<bindings = [#hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, "ReadOnly|Indirect">, #hal.pipeline.binding<storage_buffer, Indirect>], flags = Indirect>) binding(2) alignment(64) offset(%c0) flags(Indirect) {iree_gpu.use_rocdl_buffer_instructions} : !iree_tensor_ext.dispatch.tensor<writeonly:tensor<5520x1024xbf16>>
              %3 = iree_tensor_ext.dispatch.tensor.load %0, offsets = [0, 0], sizes = [5520, 2016], strides = [1, 1] : !iree_tensor_ext.dispatch.tensor<readonly:tensor<5520x2016xbf16>> -> tensor<5520x2016xbf16>
              %4 = iree_tensor_ext.dispatch.tensor.load %1, offsets = [0, 0], sizes = [1024, 2016], strides = [1, 1] : !iree_tensor_ext.dispatch.tensor<readonly:tensor<1024x2016xbf16>> -> tensor<1024x2016xbf16>
              %5 = tensor.empty() : tensor<5520x1024xf32>
              %6 = linalg.fill ins(%cst : f32) outs(%5 : tensor<5520x1024xf32>) -> tensor<5520x1024xf32>
              %7 = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>, affine_map<(d0, d1, d2) -> (d1, d2)>, affine_map<(d0, d1, d2) -> (d0, d1)>], iterator_types = ["parallel", "parallel", "reduction"]} ins(%3, %4 : tensor<5520x2016xbf16>, tensor<1024x2016xbf16>) outs(%6 : tensor<5520x1024xf32>) attrs =  {lowering_config = #iree_gpu.lowering_config<{mma_kind = #iree_gpu.mma_layout<MFMA_F32_16x16x16_BF16>, padding = [128, 128, 32], promote_operands = [0, 1], reduction = [0, 0, 2], subgroup = [4, 4, 0], workgroup = [128, 128, 0]}>} {
              ^bb0(%in: bf16, %in_0: bf16, %out: f32):
                %10 = arith.extf %in : bf16 to f32
                %11 = arith.extf %in_0 : bf16 to f32
                %12 = arith.mulf %10, %11 : f32
                %13 = arith.addf %out, %12 : f32
                linalg.yield %13 : f32
              } -> tensor<5520x1024xf32>
              %8 = tensor.empty() : tensor<5520x1024xbf16>
              %9 = linalg.generic {indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>, affine_map<(d0, d1) -> (d0, d1)>], iterator_types = ["parallel", "parallel"]} ins(%7 : tensor<5520x1024xf32>) outs(%8 : tensor<5520x1024xbf16>) {
              ^bb0(%in: f32, %out: bf16):
                %10 = arith.truncf %in : f32 to bf16
                linalg.yield %10 : bf16
              } -> tensor<5520x1024xbf16>
              iree_tensor_ext.dispatch.tensor.store %9, %2, offsets = [0, 0], sizes = [5520, 1024], strides = [1, 1] : tensor<5520x1024xbf16> -> !iree_tensor_ext.dispatch.tensor<writeonly:tensor<5520x1024xbf16>>
              return
            }
          }
        }
      }
      util.func public @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async(%arg0: !hal.buffer_view, %arg1: !hal.buffer_view, %arg2: !hal.fence, %arg3: !hal.fence) -> !hal.buffer_view attributes {inlining_policy = #util.inline.never, iree.abi.model = "coarse-fences", iree.abi.stub, preprocessing_pipeline = #util.preprocessing_pipeline<"iree-preprocessing-make-single-dispatch">} {
        %c0 = arith.constant 0 : index
        %c11304960 = arith.constant 11304960 : index
        %c4128768 = arith.constant 4128768 : index
        %c22256640 = arith.constant 22256640 : index
        %c1 = arith.constant 1 : index
        %c1024 = arith.constant 1024 : index
        %c2016 = arith.constant 2016 : index
        %c46 = arith.constant 46 : index
        %c30 = arith.constant 30 : index
        %c4 = arith.constant 4 : index
        %element_type_bf16 = hal.element_type<bf16> : i32
        %dense_row_major = hal.encoding_type<dense_row_major> : i32
        hal.buffer_view.assert<%arg0 : !hal.buffer_view> message("tensor") shape([%c4, %c30, %c46, %c2016]) type(%element_type_bf16) encoding(%dense_row_major)
        %0 = stream.tensor.import on(#hal.device.affinity<@__device_0>) %arg0 : !hal.buffer_view -> tensor<4x30x46x2016xbf16> in !stream.resource<external>{%c22256640}
        %1 = stream.timepoint.import on(#hal.device.affinity<@__device_0>) %arg2 : (!hal.fence) => !stream.timepoint
        hal.buffer_view.assert<%arg1 : !hal.buffer_view> message("tensor") shape([%c1024, %c1, %c1, %c2016]) type(%element_type_bf16) encoding(%dense_row_major)
        %2 = stream.tensor.import on(#hal.device.affinity<@__device_0>) %arg1 : !hal.buffer_view -> tensor<1024x1x1x2016xbf16> in !stream.resource<external>{%c4128768}
        %result, %result_timepoint = stream.resource.alloca uninitialized on(#hal.device.affinity<@__device_0>) await(%1) => !stream.resource<external>{%c11304960} => !stream.timepoint
        %3 = stream.cmd.execute on(#hal.device.affinity<@__device_0>) await(%result_timepoint) => with(%0 as %arg4: !stream.resource<external>{%c22256640}, %2 as %arg5: !stream.resource<external>{%c4128768}, %result as %arg6: !stream.resource<external>{%c11304960}) {
          stream.cmd.dispatch @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async_dispatch_0::@rocm_hsaco_fb::@conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async_dispatch_0_matmul_like_5520x1024x2016_bf16xbf16xf32 {
            ro %arg4[%c0 for %c22256640] : !stream.resource<external>{%c22256640},
            ro %arg5[%c0 for %c4128768] : !stream.resource<external>{%c4128768},
            wo %arg6[%c0 for %c11304960] : !stream.resource<external>{%c11304960}
          }
        } => !stream.timepoint
        stream.timepoint.chain_external on(#hal.device.affinity<@__device_0>) %3 => (%arg3 : !hal.fence)
        %4 = stream.tensor.export on(#hal.device.affinity<@__device_0>) %result : tensor<4x30x46x1024xbf16> in !stream.resource<external>{%c11304960} -> !hal.buffer_view
        util.return %4 : !hal.buffer_view
      }
      util.func public @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g(%arg0: !hal.buffer_view, %arg1: !hal.buffer_view) -> !hal.buffer_view attributes {iree.abi.stub} {
        %0 = util.null : !hal.fence
        %c-1_i32 = arith.constant -1 : i32
        %c0 = arith.constant 0 : index
        %device_0 = hal.devices.get %c0 : !hal.device
        %fence = hal.fence.create device(%device_0 : !hal.device) flags("None") : !hal.fence
        %1 = util.call @conv_2d_bfloat16_forward_4x30x46x2016_nhwc_1024x1x1x2016_fhwc_nhwf_1x1s_0x0p_1x1d_1g$async(%arg0, %arg1, %0, %fence) : (!hal.buffer_view, !hal.buffer_view, !hal.fence, !hal.fence) -> !hal.buffer_view
        %status = hal.fence.await until([%fence]) timeout_millis(%c-1_i32) flags("None") : i32
        util.return %1 : !hal.buffer_view
      }
    }
    

    compile command

    iree-compile  under_aligned_configured.mlir -o under_aligned_configured.vmfb --compile-from=executable-configurations --mlir-print-ir-after-all &> under_aligned_dump.mlir
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions