[Mlir-commits] [mlir] 0d3abdc - [mlir][Linalg] Fix formatting of generated docs markdown

Benjamin Maxwell llvmlistbot at llvm.org
Wed Aug 16 08:09:33 PDT 2023


Author: Benjamin Maxwell
Date: 2023-08-16T15:08:51Z
New Revision: 0d3abdc263546907864599e6f450501742212c79

URL: https://github.com/llvm/llvm-project/commit/0d3abdc263546907864599e6f450501742212c79
DIFF: https://github.com/llvm/llvm-project/commit/0d3abdc263546907864599e6f450501742212c79.diff

LOG: [mlir][Linalg] Fix formatting of generated docs markdown

This patch prevents `mlir-linalg-ods-yaml-gen` from adding extra
whitespace around the summary and description fields. This broke the
_italics_ of the summary as _ this _ is not recognised by markdown.
It also meant the first line of the description was in a code block
  as it was indented two spaces.

The separator between summary and description has also been updated to
two newlines. This was already followed and prevents line wrapping the
summary putting part of it in the description.

These issues can be currently seen at: https://mlir.llvm.org/docs/Dialects/Linalg/

Reviewed By: awarzynski

Differential Revision: https://reviews.llvm.org/D157853

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
    mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
    mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
index d638cdad832cb5..37ff88087bc69c 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgNamedStructuredOps.yaml
@@ -1140,11 +1140,14 @@ structured_op: !LinalgStructuredOpConfig
 metadata: !LinalgOpMetadata
   name: batch_mmt4d
   cpp_class_name: BatchMmt4DOp
-  doc: "Performs a batched matrix-matrix-transpose multiplication of two\nbatched-4D\
-    \ (5D) inputs.\n\nBesides the outermost batch dimension has the same semantic\
-    \ as\nlinalg.batch_matmul, the 
diff erences from linalg.batch_matmul in the\nnon-batch\
-    \ dimensions are the same as linalg.mmt4d vs. linalg.matmul. See the\ndescription\
-    \ of lingalg.mmt4d."
+  doc: |-
+    Performs a batched matrix-matrix-transpose multiplication of two batched-4D
+    (5D) inputs.
+
+    Besides the outermost batch dimension has the same semantic as
+    linalg.batch_matmul, the 
diff erences from linalg.batch_matmul in the
+    non-batch dimensions are the same as linalg.mmt4d vs. linalg.matmul. See the
+    description of lingalg.mmt4d.
   implements:
   - LinalgContractionOpInterface
 structured_op: !LinalgStructuredOpConfig

diff  --git a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
index 5d7048d5d52bdd..1f7f14a9f51f34 100644
--- a/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
+++ b/mlir/test/mlir-linalg-ods-gen/test-linalg-ods-yaml-gen.yaml
@@ -62,10 +62,8 @@ structured_op: !LinalgStructuredOpConfig
 
 # ODS-LABEL:  def Test1Op : LinalgStructuredBase_Op<"test1"
 
-#       ODS:  let summary = [{ Title. }];
-#  ODS-NEXT:  let description = [{
-#  ODS-NEXT:    Detailed description.
-#  ODS-NEXT:  }];
+#       ODS:  let summary = [{Title.}];
+#  ODS-NEXT:  let description = [{Detailed description.}];
 
 #       ODS:  let arguments =
 #  ODS-NEXT:    Variadic<AnyType>:$inputs,

diff  --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
index aeda1b8ba0258a..7f527197349b32 100644
--- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
+++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp
@@ -693,14 +693,13 @@ static LogicalResult generateNamedGenericOpOds(LinalgOpConfig &opConfig,
   std::string doc;
   if (opConfig.metadata->doc) {
     static const char structuredOpDocFmt[] = R"FMT(
-  let summary = [{ {0} }];
-  let description = [{
-    {1}
-  }];
+  let summary = [{{{0}}];
+  let description = [{{{1}}];
 )FMT";
     StringRef summary, description;
     std::tie(summary, description) =
-        StringRef(*opConfig.metadata->doc).trim().split('\n');
+        StringRef(*opConfig.metadata->doc).trim().split("\n\n");
+
     doc = llvm::formatv(structuredOpDocFmt, summary.trim(), description.trim());
   }
 


        


More information about the Mlir-commits mailing list