iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.83k stars 610 forks source link

[Encoding] Teach the EncodingAttr about alias #19024

Open hanhanW opened 3 days ago

hanhanW commented 3 days ago

Request description

Currently the tests related to encodings we have are written with using alias. It reduces a lot of visual noise. However, it is not implemented in printer, so the IR dumps still have those visual noise. What we can do is adding the support for encoding attributes, which should make IR dumps friendly. Filing an issue for tracking the feature. Below is an example that we can follow. (Unfortunately I did not find the MLIR documentations. It says that it is doable, but it does not teach me how. I spent some time to browse the code and have a rough picture about how it can be done, hopefully.)

https://github.com/iree-org/iree/blob/1444755ad2e19707f0f5461cf9e499d8f3c093a9/compiler/src/iree/compiler/Dialect/HAL/IR/HALDialect.cpp#L31-L52

cc @Max191 who might be interested in it.

What component(s) does this issue relate to?

Compiler, MLIR

Additional context

No response

hanhanW commented 3 days ago

Here is an example that we use attribute aliases in lit tests.

https://github.com/iree-org/iree/blob/1444755ad2e19707f0f5461cf9e499d8f3c093a9/compiler/src/iree/compiler/Codegen/Common/CPU/test/llvmcpu_materialize_encoding.mlir#L3-L17

Here is an example that it prints A LOT OF chars in IR dump. It does not show up because we elide the types in matmul.

https://github.com/iree-org/iree/blob/1444755ad2e19707f0f5461cf9e499d8f3c093a9/compiler/src/iree/compiler/DispatchCreation/test/set_encoding.mlir#L3-L26

I personally find that the IR is hard to read when they are all in one line. The support should help it a lot, IMO.

hanhanW commented 3 days ago

Actually I think I'll need this feature in my prototype. It makes IR much more friendly. Assigning it to myself for now

Max191 commented 2 days ago

Cool! This would be so nice to have!