Skip to content

[GPU] Failed to materialize encodings for a dispatch in padding approach #20362

Closed

Description

@hanhanW

To repro:

Run: iree-opt --pass-pipeline="builtin.module(func.func(iree-codegen-materialize-encoding-into-padding))" ~/repro.mlir

#encoding = #iree_encoding.encoding<operand_index = 1 : index, op_type =  matmul, element_types = [f16, f16, f32], layouts = [#iree_encoding.pad_encoding_layout<[0, 64]>]>
#pipeline_layout = #hal.pipeline.layout<constants = 4, bindings = [#hal.pipeline.binding<storage_buffer, ReadOnly>, #hal.pipeline.binding<storage_buffer>], flags = None>
module {
  func.func @_encoding_0_encode_4096x4096xf16_to_4096x4096xf16() {
    %c32_i64 = arith.constant 32 : i64
    %0 = hal.interface.constant.load layout(#pipeline_layout) ordinal(0) : i32
    %1 = hal.interface.constant.load layout(#pipeline_layout) ordinal(1) : i32
    %2 = hal.interface.constant.load layout(#pipeline_layout) ordinal(2) : i32
    %3 = hal.interface.constant.load layout(#pipeline_layout) ordinal(3) : i32
    %4 = arith.extui %0 : i32 to i64
    %5 = arith.extui %1 : i32 to i64
    %6 = arith.shli %5, %c32_i64 : i64
    %7 = arith.ori %4, %6 : i64
    %8 = arith.index_castui %7 : i64 to index
    %9 = arith.extui %2 : i32 to i64
    %10 = arith.extui %3 : i32 to i64
    %11 = arith.shli %10, %c32_i64 : i64
    %12 = arith.ori %9, %11 : i64
    %13 = arith.index_castui %12 : i64 to index
    %14 = hal.interface.binding.subspan layout(#pipeline_layout) binding(0) alignment(64) offset(%8) flags(ReadOnly) : !flow.dispatch.tensor<readonly:tensor<4096x4096xf16>>
    %15 = hal.interface.binding.subspan layout(#pipeline_layout) binding(1) alignment(64) offset(%13) flags("None") : !flow.dispatch.tensor<writeonly:tensor<4096x4096xf16, #encoding>>
    %16 = flow.dispatch.tensor.load %14, offsets = [0, 0], sizes = [4096, 4096], strides = [1, 1] : !flow.dispatch.tensor<readonly:tensor<4096x4096xf16>> -> tensor<4096x4096xf16>
    %17 = iree_encoding.set_encoding %16 : tensor<4096x4096xf16> -> tensor<4096x4096xf16, #encoding>
    flow.dispatch.tensor.store %17, %15, offsets = [0, 0], sizes = [4096, 4096], strides = [1, 1] : tensor<4096x4096xf16, #encoding> -> !flow.dispatch.tensor<writeonly:tensor<4096x4096xf16, #encoding>>
    return
  }
}

Activity

  1. self-assigned this
    on Mar 24, 2025
  2. hanhanW commented on Mar 24, 2025

    @hanhanW
    ContributorAuthor

    I have a fix here, but it is not very clean. hanhanW@1ea6a95
    I think the insert_slice op creation is part of set_encoding lowering, but not the store op lowering. Currently, we abuse EncodingNopLayoutAttr to handle the lowering.

    This work really ties to #20160 where we need to move type inference and more logic to interface methods. So we can call the methods directly in the lowering.

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