Skip to content

Commit 5195d45

Browse files
author
Matteo Franciolini
authored
[mlir][resources] Add elideLargeResourceString OpPrintingFlags API (#71829)
Allows to set `resourceStringCharLimit` through an OpPrintingFlags API to avoid printing resources larger than the privided limit.
1 parent 247eb13 commit 5195d45

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

mlir/include/mlir/IR/OperationSupport.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,12 @@ class OpPrintingFlags {
11311131
/// elements.
11321132
OpPrintingFlags &elideLargeElementsAttrs(int64_t largeElementLimit = 16);
11331133

1134+
/// Enables the elision of large resources strings by omitting them from the
1135+
/// `dialect_resources` section. The `largeResourceLimit` is used to configure
1136+
/// what is considered to be a "large" resource by providing an upper limit to
1137+
/// the string size.
1138+
OpPrintingFlags &elideLargeResourceString(int64_t largeResourceLimit = 64);
1139+
11341140
/// Enable or disable printing of debug information (based on `enable`). If
11351141
/// 'prettyForm' is set to true, debug information is printed in a more
11361142
/// readable 'pretty' form. Note: The IR generated with 'prettyForm' is not

mlir/lib/IR/AsmPrinter.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ OpPrintingFlags::elideLargeElementsAttrs(int64_t largeElementLimit) {
226226
return *this;
227227
}
228228

229+
OpPrintingFlags &
230+
OpPrintingFlags::elideLargeResourceString(int64_t largeResourceLimit) {
231+
resourceStringCharLimit = largeResourceLimit;
232+
return *this;
233+
}
234+
229235
/// Enable printing of debug information. If 'prettyForm' is set to true,
230236
/// debug information is printed in a more readable 'pretty' form.
231237
OpPrintingFlags &OpPrintingFlags::enableDebugInfo(bool enable,

0 commit comments

Comments
 (0)