[Mlir-commits] [mlir] [mlir][resources] Add elideLargeResourceString OpPrintingFlags API (PR #71829)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Nov 9 08:57:49 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core
Author: Matteo Franciolini (mfrancio)
<details>
<summary>Changes</summary>
Allows to set `resourceStringCharLimit` through an OpPrintingFlags API
to avoid printing resources larger than the privided limit.
---
Full diff: https://github.com/llvm/llvm-project/pull/71829.diff
2 Files Affected:
- (modified) mlir/include/mlir/IR/OperationSupport.h (+6)
- (modified) mlir/lib/IR/AsmPrinter.cpp (+6)
``````````diff
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index bb3d1643e1687ab..6a5ec129ad564b4 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -1131,6 +1131,12 @@ class OpPrintingFlags {
/// elements.
OpPrintingFlags &elideLargeElementsAttrs(int64_t largeElementLimit = 16);
+ /// Enables the elision of large resources strings by omitting them from the
+ /// `dialect_resources` section. The `largeResourceLimit` is used to configure
+ /// what is considered to be a "large" resource by providing an upper limit to
+ /// the string size.
+ OpPrintingFlags &elideLargeResourceString(int64_t largeResourceLimit = 64);
+
/// Enable or disable printing of debug information (based on `enable`). If
/// 'prettyForm' is set to true, debug information is printed in a more
/// readable 'pretty' form. Note: The IR generated with 'prettyForm' is not
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index 82e1e96229b79e0..dae7fdd40b5456c 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -226,6 +226,12 @@ OpPrintingFlags::elideLargeElementsAttrs(int64_t largeElementLimit) {
return *this;
}
+OpPrintingFlags &
+OpPrintingFlags::elideLargeResourceString(int64_t largeResourceLimit) {
+ resourceStringCharLimit = largeResourceLimit;
+ return *this;
+}
+
/// Enable printing of debug information. If 'prettyForm' is set to true,
/// debug information is printed in a more readable 'pretty' form.
OpPrintingFlags &OpPrintingFlags::enableDebugInfo(bool enable,
``````````
</details>
https://github.com/llvm/llvm-project/pull/71829
More information about the Mlir-commits
mailing list