Skip to content

[mlir][linalg] Tiling implementation for linalg.generic will result in assert/crash if indexing expressions have negative multiplicative coefficients #113021

@christopherbate

Description

@christopherbate

Any indexing map that contains negative multiplicative coefficients will crash due to an assertion here. Such maps are sometimes produced to represent reversed iteration over some input dimension.

The condition should be checked much higher up in the call stack (e.g. in Linalg/Transforms/TilingInterfaceImpl.cpp); I think there's not much awareness of this limitation.

Here's a test case:

#map = affine_map<(d0) -> (d0)>
#map1 = affine_map<(d0) -> (-d0 + 7)>

func.func @test(%arg0: tensor<8xi8>, %arg1: tensor<8xi8>) -> tensor<8xi8> {
  %0 = linalg.generic {
    indexing_maps = [#map1, #map],
    iterator_types = ["parallel"]}
  ins(%arg0 : tensor<8xi8>)
  outs(%arg1 : tensor<8xi8>) {
  ^bb0(%in: i8, %out: i8):
    linalg.yield %in : i8
  } -> tensor<8xi8>
  return %0 : tensor<8xi8>
}


module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
    %0 = transform.structured.match ops{["linalg.generic"]} in %arg1 : (!transform.any_op) -> !transform.any_op
    %1:2 = transform.structured.tile_using_for
      %0 tile_sizes [2] : (!transform.any_op) -> (!transform.any_op, !transform.any_op)
     transform.yield
  }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions