[Mlir-commits] [mlir] [mlir][mesh] Use tensor shape notation for the shape of a cluster (PR #73826)
Mehdi Amini
llvmlistbot at llvm.org
Tue Dec 5 19:23:45 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 \"[]\".";
+ }
----------------
joker-eph wrote:
If you don't intent to support this, then I would start with this:
```suggestion
bool hasOpeningSquare = succeeded(parser.parseOptionalLSquare());
if (hasOpeningSquare) {
if (failed(parser.parseRSquare()))
return parser.emitError(parser.getCurrentLocation())
<< "Failed parsing dimension list.";
return DenseI64ArrayAttr::get(parser.getContext(), {});
}
```
https://github.com/llvm/llvm-project/pull/73826
More information about the Mlir-commits
mailing list