summaryrefslogtreecommitdiff
path: root/mlir/lib/Bytecode
diff options
context:
space:
mode:
authorAndrzej Warzynski <andrzej.warzynski@arm.com>2023-06-19 13:01:11 +0100
committerAndrzej Warzynski <andrzej.warzynski@gmail.com>2023-06-27 19:21:59 +0100
commit79c83e12c8884fa46f2f2594836af93474f6ca5a (patch)
tree593c0231f20d64a70de7faaf51cc3b7f7f8b9cf5 /mlir/lib/Bytecode
parentc88f3e209cc4ccaa50754507880c553699e988b3 (diff)
[mlir][VectorType] Allow arbitrary dimensions to be scalable
At the moment, only the trailing dimensions in the vector type can be scalable, i.e. this is supported: vector<2x[4]xf32> and this is not allowed: vector<[2]x4xf32> This patch extends the vector type so that arbitrary dimensions can be scalable. To this end, an array of bool values is added to every vector type to denote whether the corresponding dimensions are scalable or not. For example, for this vector: vector<[2]x[3]x4xf32> the following array would be created: {true, true, false}. Additionally, the current syntax: vector<[2x3]x4xf32> is replaced with: vector<[2]x[3]x4xf32> This is primarily to simplify parsing (this way, the parser can easily process one dimension at a time rather than e.g. tracking whether "scalable block" has been entered/left). NOTE: The `isScalableDim` parameter of `VectorType` (introduced in this patch) makes `numScalableDims` redundant. For the time being, `numScalableDims` is preserved to facilitate the transition between the two parameters. `numScalableDims` will be removed in one of the subsequent patches. This change is a part of a larger effort to enable scalable vectorisation in Linalg. See this RFC for more context: * https://discourse.llvm.org/t/rfc-scalable-vectorisation-in-linalg/ Differential Revision: https://reviews.llvm.org/D153372
Diffstat (limited to 'mlir/lib/Bytecode')
-rw-r--r--mlir/lib/Bytecode/Reader/BytecodeReader.cpp4
-rw-r--r--mlir/lib/Bytecode/Writer/BytecodeWriter.cpp2
-rw-r--r--mlir/lib/Bytecode/Writer/IRNumbering.cpp1
3 files changed, 7 insertions, 0 deletions
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index 5b313af8cee3..8269546d9836 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -994,6 +994,10 @@ public:
return success();
}
+ LogicalResult readBool(bool &result) override {
+ return reader.parseByte(result);
+ }
+
private:
AttrTypeReader &attrTypeReader;
StringSectionReader &stringReader;
diff --git a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
index 936117aa2b8f..f02389927019 100644
--- a/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
+++ b/mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
@@ -396,6 +396,8 @@ public:
reinterpret_cast<const uint8_t *>(blob.data()), blob.size()));
}
+ void writeOwnedBool(bool value) override { emitter.emitByte(value); }
+
int64_t getBytecodeVersion() const override { return bytecodeVersion; }
private:
diff --git a/mlir/lib/Bytecode/Writer/IRNumbering.cpp b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
index 36f7a268a6a1..2547d815c12b 100644
--- a/mlir/lib/Bytecode/Writer/IRNumbering.cpp
+++ b/mlir/lib/Bytecode/Writer/IRNumbering.cpp
@@ -45,6 +45,7 @@ struct IRNumberingState::NumberingDialectWriter : public DialectBytecodeWriter {
// file locations.
}
void writeOwnedBlob(ArrayRef<char> blob) override {}
+ void writeOwnedBool(bool value) override {}
int64_t getBytecodeVersion() const override {
llvm_unreachable("unexpected querying of version in IRNumbering");