Skip to content

Instantly share code, notes, and snippets.

@pashu123
Created April 23, 2024 15:51
Show Gist options
  • Save pashu123/ecf80b5ec6ae6f2abefaa67593c042dc to your computer and use it in GitHub Desktop.
Save pashu123/ecf80b5ec6ae6f2abefaa67593c042dc to your computer and use it in GitHub Desktop.
%19 = scf.for %arg3 = %c0 to %11 step %c1 iter_args(%arg4 = %16) -> (tensor<?x4x64x16x1xf16>) {
%20 = scf.for %arg5 = %c0 to %c4 step %c1 iter_args(%arg6 = %arg4) -> (tensor<?x4x64x16x1xf16>) {
%21 = scf.for %arg7 = %c0 to %c64 step %c1 iter_args(%arg8 = %arg6) -> (tensor<?x4x64x16x1xf16>) {
%22 = affine.apply affine_map<(d0) -> (d0 * 16)>(%arg5)
%extracted_slice = tensor.extract_slice %18[%22, %arg7] [16, 1] [1, 1] : tensor<64x64xf16> to tensor<16x1xf16>
%23 = tensor.empty() : tensor<1x16x1xf16>
%24 = linalg.generic {indexing_maps = [affine_map<(d0, d1, d2) -> (d1, d2)>, affine_map<(d0, d1, d2) -> (d0, d1, d2)>], iterator_types = ["parallel", "parallel", "parallel"]} ins(%extracted_slice : tensor<16x1xf16>) outs(%23 : tensor<1x16x1xf16>) attrs = {lowering_config = #iree_codegen.lowering_config<tile_sizes = [[64, 64, 64], [1, 16, 1], [0, 0, 0], [0, 0, 0]]>} {
^bb0(%in: f16, %out: f16):
linalg.yield %in : f16
} -> tensor<1x16x1xf16>
%extracted_slice_0 = tensor.extract_slice %arg8[%arg3, %arg5, %arg7, 0, 0] [1, 1, 1, 16, 1] [1, 1, 1, 1, 1] : tensor<?x4x64x16x1xf16> to tensor<1x1x1x16x1xf16>
%pack = tensor.pack %24 outer_dims_perm = [0, 1, 2] inner_dims_pos = [1, 2] inner_tiles = [16, 1] into %extracted_slice_0 {lowering_config = #iree_codegen.lowering_config<tile_sizes = [[64, 4, 64], [1, 1, 1], [0, 0, 0], [0, 0, 0]]>} : tensor<1x16x1xf16> -> tensor<1x1x1x16x1xf16>
%inserted_slice = tensor.insert_slice %pack into %arg8[%arg3, %arg5, %arg7, 0, 0] [1, 1, 1, 16, 1] [1, 1, 1, 1, 1] : tensor<1x1x1x16x1xf16> into tensor<?x4x64x16x1xf16>
scf.yield %inserted_slice : tensor<?x4x64x16x1xf16>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment