Skip to content

ukernels: stop abusing signless as signed - #15338

Merged
bjacob merged 3 commits into
iree-org:mainfrom
bjacob:ukernels-signedness
Oct 30, 2023
Merged

bjacob merged 3 commits into
iree-org:mainfrom
bjacob:ukernels-signedness

Conversation

@bjacob

@bjacob bjacob commented Oct 30, 2023 •

Copy link
Copy Markdown
Collaborator

In MLIR we are chronically abusing signless types as signed. Ongoing discussion at #15241, etc. At least in ukernels we are insulated enough from the compiler code that we don't have to replicate the same confusion. So, just because linalg named matmul ops want int8 x int8 -> int32 matmuls to be represented as i8 x i8 -> i32 even though these are signless types and this is silently interpreting these as signed, we didn't have to let that lower to a _i8i8i32 ukernel, we could instead more properly represent that as a _s8s8s32 ukernel.

Fixing this now paves the way for unsigned LHS/RHS support in ukernels, a step in #15158, without adding more tech debt.

The bulk of is PR is just a regex substitution:

find runtime/src/ compiler/src/ -type f | xargs sed -i 's/IREE_UK_FLAG_MMT4D_TYPE_I8I8I32/IREE_UK_FLAG_MMT4D_TYPE_S8S8S32/g;s/iree_uk_mmt4d_type_i8i8i32/iree_uk_mmt4d_type_s8s8s32/g;s/iree_uk_mmt4d_tile_i8i8i32/iree_uk_mmt4d_tile_s8s8s32/g;s/iree_mmt4d_reference_innerloop_i8i8i32/iree_mmt4d_reference_innerloop_s8s8s32/g'

@bjacob
bjacob force-pushed the ukernels-signedness branch from 5708121 to 3aa6099 Compare October 30, 2023 14:12
@bjacob
bjacob marked this pull request as ready for review October 30, 2023 14:22
@bjacob
bjacob merged commit 41e7289 into iree-org:main Oct 30, 2023
ramiro050 pushed a commit to ramiro050/iree that referenced this pull request Dec 19, 2023
In MLIR we are chronically abusing signless types as signed. Ongoing
discussion at iree-org#15241, etc. At least in ukernels we are insulated enough
from the compiler code that we don't have to replicate the same
confusion. So, just because `linalg` named matmul ops want `int8 x int8
-> int32` matmuls to be represented as `i8 x i8 -> i32` even though
these are signless types and this is silently interpreting these as
signed, we didn't have to let that lower to a `_i8i8i32` ukernel, we
could instead more properly represent that as a `_s8s8s32` ukernel.

Fixing this now paves the way for unsigned LHS/RHS support in ukernels,
a step in iree-org#15158, without adding more tech debt.

The bulk of is PR is just a regex substitution:

```
find runtime/src/ compiler/src/ -type f | xargs sed -i 's/IREE_UK_FLAG_MMT4D_TYPE_I8I8I32/IREE_UK_FLAG_MMT4D_TYPE_S8S8S32/g;s/iree_uk_mmt4d_type_i8i8i32/iree_uk_mmt4d_type_s8s8s32/g;s/iree_uk_mmt4d_tile_i8i8i32/iree_uk_mmt4d_tile_s8s8s32/g;s/iree_mmt4d_reference_innerloop_i8i8i32/iree_mmt4d_reference_innerloop_s8s8s32/g'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants