[Mlir-commits] [mlir] [mlir] fix references of attributes which are not defined earlier (PR #134364)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Apr 4 05:48:57 PDT 2025


tdanyluk wrote:

Fair question, but there are currently no tests for generate-test-checks.py and adding them would probably take too much of my working time.

If you just want to try this change, you can make a file (test-input.txt):
```
{
    #my_attr = my.attr<[1, 2, 3]>
    %0 = toy.reshape %arg0 {shape = #my_attr} : (tensor<3xf32>) -> tensor<3xf32>
    %0 = toy.reshape %arg0 {shape = #toy.shape<[1, 2, 3]>} : (tensor<3xf32>) -> tensor<3xf32>
}
```

run cat test-input.txt | python3 generate-test-checks.py  --source test-input.txt

Earlier version would output:
// CHECK-LABEL:     #[[$ATTR_0]] = my.attr<[1, 2, 3]>
// CHECK:           %[[VAL_0:.*]] = toy.reshape %[[VAL_1:.*]] {shape = #[[$ATTR_0]]} : (tensor<3xf32>) -> tensor<3xf32>
// CHECK:           %[[VAL_0]] = toy.reshape %[[VAL_1]] {shape = #[[?]]<[1, 2, 3]>} : (tensor<3xf32>) -> tensor<3xf32>

New version would output:
// CHECK-LABEL:     #[[$ATTR_0]] = my.attr<[1, 2, 3]>
// CHECK:           %[[VAL_0:.*]] = toy.reshape %[[VAL_1:.*]] {shape = #[[$ATTR_0]]} : (tensor<3xf32>) -> tensor<3xf32>
// CHECK:           %[[VAL_0]] = toy.reshape %[[VAL_1]] {shape = #toy.shape<[1, 2, 3]>} : (tensor<3xf32>) -> tensor<3xf32>

So the case where the attribute is defined locally is unchanged, but the case where it's not is different.

https://github.com/llvm/llvm-project/pull/134364


More information about the Mlir-commits mailing list