[Mlir-commits] [mlir] [mlir][vector][nfc] Improve comments in `getCompressedMaskOp` (PR #115663)

Andrzej Warzyński llvmlistbot at llvm.org
Mon Nov 11 07:16:36 PST 2024


================
@@ -36,24 +36,33 @@ using namespace mlir;
 #define DBGSNL() (llvm::dbgs() << "\n")
 #define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n")
 
-/// Returns a compressed mask. The mask value is set only if any mask is present
-/// in the scale range. E.g., if `scale` equals to 2, and `intraDataOffset`
-/// equals to 1 (intraDataOffset strictly smaller than scale), the following
-/// mask:
+/// Returns a compressed mask. For example, when emulating `i8` with `i32` and
+/// when the number of source elements spans two `i32` elements, this method
+/// will compress `vector<8xi1>` into `vector<2xi1>`.
----------------
banach-space wrote:

> when emulating an eight element `i8`vector with `i32` and when the number of source elements spans two `i32`elements, this method will compress `vector<8xi1>` into `vector<2xi1>`.

Thanks! I want to make sure that I understand your suggestion correctly  and that we are on the same page :)

Below is some ASCII explaining what I had in mind.

**CASE 1**

In my comment, I was thinking about this example of 2 `i8` elements  (`value 1` and `value 2`) occupying 2 `i32` elements:

```
32-bit Integer 1: | 00000000 | 00000000 | 00000000 | 00001010 |
                  |          |          |          |  value 1 |

32-bit Integer 2: | 00001111 | 00000000 | 00000000 | 00000000 |
                  | value 2  |          |          |          |
```

In this case, the uncompressed mask would be `vector<2xi1> = {1, 1}`(2 x `i8`), and the compressed one would ... also be `vector<2xi1> = {1, 1}` (**2** x `i32`). 

**CASE 2**
Here's a similar example, but the `i8` values are distributed differently: 
```
32-bit Integer 1: | 00000000 | 00000000 | 00001111 | 00001010 |
                  |          |          | value 2  | value 1  |
```
In this case, the uncompressed mask would be `vector<2xi1> = {1, 1}` (2 x `i8`), and the compressed one would  be `vector<1xi1> = {1}` (**1** x `i32`). 

**QUESTION 1**

Is the above consistent with how you understand all of this?

**QUESTION 2**
In your suggestion you mentioned ` an eight element i8vector` - are you proposing to build a comment around `vector<8xi8>`, as opposed to `vector<2xi8>` as I did? I don't mind, I mostly wanted to keep things simple and straightforward 😅 

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


More information about the Mlir-commits mailing list