[Mlir-commits] [mlir] 5195d45 - [mlir][resources] Add elideLargeResourceString OpPrintingFlags API (#71829)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Nov 9 16:29:02 PST 2023
Author: Matteo Franciolini
Date: 2023-11-09T16:28:58-08:00
New Revision: 5195d458587b02f3edf1347fae53417a74538648
URL: https://github.com/llvm/llvm-project/commit/5195d458587b02f3edf1347fae53417a74538648
DIFF: https://github.com/llvm/llvm-project/commit/5195d458587b02f3edf1347fae53417a74538648.diff
LOG: [mlir][resources] Add elideLargeResourceString OpPrintingFlags API (#71829)
Allows to set `resourceStringCharLimit` through an OpPrintingFlags API
to avoid printing resources larger than the privided limit.
Added:
Modified:
mlir/include/mlir/IR/OperationSupport.h
mlir/lib/IR/AsmPrinter.cpp
Removed:
################################################################################
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,
More information about the Mlir-commits
mailing list