[Mlir-commits] [mlir] [MLIR] support dynamic indexing in `VectorEmulateNarrowTypes` (PR #114169)
Han-Chung Wang
llvmlistbot at llvm.org
Mon Nov 4 11:13:18 PST 2024
================
@@ -129,26 +128,80 @@ static FailureOr<Operation *> getCompressedMaskOp(OpBuilder &rewriter,
return newMask;
}
+/// Extracts 1-D subvector from a 1-D vector. It is a wrapper function for
+/// emitting `vector.extract_strided_slice`.
static Value extractSubvectorFrom(RewriterBase &rewriter, Location loc,
- VectorType extractType, Value vector,
+ VectorType extractType, Value source,
int64_t frontOffset, int64_t subvecSize) {
+ auto vectorType = dyn_cast<VectorType>(source.getType());
+ assert(vectorType && vectorType.getRank() == 1 &&
+ extractType.getRank() == 1 &&
+ "expected 1-D source and destination types");
----------------
hanhanW wrote:
nit1: I'd use `cast` which already asserts it for you.
nit2: I'd wrap all the conditions with a pair of brace. We've seen some bugs in assertions when there are **OR** (i.e., `||`) operations. Just in case to prevent a similar bug here.
```suggestion
auto vectorType = cast<VectorType>(source.getType());
assert((vectorType.getRank() == 1 &&
extractType.getRank() == 1) &&
"expected 1-D source and destination types");
```
https://github.com/llvm/llvm-project/pull/114169
More information about the Mlir-commits
mailing list