[Mlir-commits] [mlir] [mlir][mesh] Use tensor shape notation for the shape of a cluster (PR #73826)
Boian Petkantchin
llvmlistbot at llvm.org
Wed Dec 6 08:48:15 PST 2023
================
@@ -3911,3 +3930,42 @@ void Block::printAsOperand(raw_ostream &os, AsmState &state) {
OperationPrinter printer(os, state.getImpl());
printer.printBlockName(this);
}
+
+//===--------------------------------------------------------------------===//
+// Custom printers
+//===--------------------------------------------------------------------===//
+namespace mlir {
+
+void printDimensionList(OpAsmPrinter &printer, Operation *op,
+ ArrayRef<int64_t> dimensions) {
+ if (dimensions.empty())
+ printer << "[";
+ printer.printDimensionList(dimensions);
+ if (dimensions.empty())
+ printer << "]";
+}
+
+ParseResult parseDimensionList(OpAsmParser &parser,
+ DenseI64ArrayAttr &dimensions) {
+ bool hasOpeningSquare = succeeded(parser.parseOptionalLSquare());
+ SmallVector<int64_t> shapeArr;
+ if (failed(parser.parseDimensionList(shapeArr, true, false))) {
+ return parser.emitError(parser.getCurrentLocation())
+ << "Failed parsing dimension list.";
+ }
+ if (shapeArr.empty() && !hasOpeningSquare) {
+ return parser.emitError(parser.getCurrentLocation())
+ << "Failed parsing dimension list. Did you mean an empty list? It "
+ "must be "
+ "denoted by \"[]\".";
+ }
----------------
sogartar wrote:
I refactored it to not allow non-empty shapes like `[2x4]` and added some tests.
https://github.com/llvm/llvm-project/pull/73826
More information about the Mlir-commits
mailing list