[Mlir-commits] [mlir] [mlir][resources] Add elideLargeResourceString OpPrintingFlags API (PR #71829)
Matteo Franciolini
llvmlistbot at llvm.org
Thu Nov 9 08:57:19 PST 2023
https://github.com/mfrancio created https://github.com/llvm/llvm-project/pull/71829
Allows to set `resourceStringCharLimit` through an OpPrintingFlags API
to avoid printing resources larger than the privided limit.
>From f9acfeb906b86305d823c6b74fb6e0501242cda9 Mon Sep 17 00:00:00 2001
From: Matteo Franciolini <m_franciolini at apple.com>
Date: Thu, 9 Nov 2023 08:34:56 -0800
Subject: [PATCH] [mlir][resources] Add elideLargeResourceString
OpPrintingFlags API
Allows to set `resourceStringCharLimit` through an OpPrintingFlags API
to avoid printing resources larger than the privided limit.
---
mlir/include/mlir/IR/OperationSupport.h | 6 ++++++
mlir/lib/IR/AsmPrinter.cpp | 6 ++++++
2 files changed, 12 insertions(+)
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