@@ -97,6 +97,10 @@ static const char kOperationPrintDocstring[] =
97
97
binary: Whether to write bytes (True) or str (False). Defaults to False.
98
98
large_elements_limit: Whether to elide elements attributes above this
99
99
number of elements. Defaults to None (no limit).
100
+ large_resource_limit: Whether to elide resource attributes above this
101
+ number of characters. Defaults to None (no limit). If large_elements_limit
102
+ is set and this is None, the behavior will be to use large_elements_limit
103
+ as large_resource_limit.
100
104
enable_debug_info: Whether to print debug/location information. Defaults
101
105
to False.
102
106
pretty_debug_info: Whether to format debug information for easier reading
@@ -1303,6 +1307,7 @@ void PyOperation::checkValid() const {
1303
1307
}
1304
1308
1305
1309
void PyOperationBase::print (std::optional<int64_t > largeElementsLimit,
1310
+ std::optional<int64_t > largeResourceLimit,
1306
1311
bool enableDebugInfo, bool prettyDebugInfo,
1307
1312
bool printGenericOpForm, bool useLocalScope,
1308
1313
bool useNameLocAsPrefix, bool assumeVerified,
@@ -1314,10 +1319,10 @@ void PyOperationBase::print(std::optional<int64_t> largeElementsLimit,
1314
1319
fileObject = nb::module_::import_ (" sys" ).attr (" stdout" );
1315
1320
1316
1321
MlirOpPrintingFlags flags = mlirOpPrintingFlagsCreate ();
1317
- if (largeElementsLimit) {
1322
+ if (largeElementsLimit)
1318
1323
mlirOpPrintingFlagsElideLargeElementsAttrs (flags, *largeElementsLimit);
1319
- mlirOpPrintingFlagsElideLargeResourceString (flags, *largeElementsLimit);
1320
- }
1324
+ if (largeResourceLimit)
1325
+ mlirOpPrintingFlagsElideLargeResourceString (flags, *largeResourceLimit);
1321
1326
if (enableDebugInfo)
1322
1327
mlirOpPrintingFlagsEnableDebugInfo (flags, /* enable=*/ true ,
1323
1328
/* prettyForm=*/ prettyDebugInfo);
@@ -1405,6 +1410,7 @@ void PyOperationBase::walk(
1405
1410
1406
1411
nb::object PyOperationBase::getAsm (bool binary,
1407
1412
std::optional<int64_t > largeElementsLimit,
1413
+ std::optional<int64_t > largeResourceLimit,
1408
1414
bool enableDebugInfo, bool prettyDebugInfo,
1409
1415
bool printGenericOpForm, bool useLocalScope,
1410
1416
bool useNameLocAsPrefix, bool assumeVerified,
@@ -1416,6 +1422,7 @@ nb::object PyOperationBase::getAsm(bool binary,
1416
1422
fileObject = nb::module_::import_ (" io" ).attr (" StringIO" )();
1417
1423
}
1418
1424
print (/* largeElementsLimit=*/ largeElementsLimit,
1425
+ /* largeResourceLimit=*/ largeResourceLimit,
1419
1426
/* enableDebugInfo=*/ enableDebugInfo,
1420
1427
/* prettyDebugInfo=*/ prettyDebugInfo,
1421
1428
/* printGenericOpForm=*/ printGenericOpForm,
@@ -3348,6 +3355,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
3348
3355
[](PyOperationBase &self) {
3349
3356
return self.getAsm (/* binary=*/ false ,
3350
3357
/* largeElementsLimit=*/ std::nullopt ,
3358
+ /* largeResourceLimit=*/ std::nullopt ,
3351
3359
/* enableDebugInfo=*/ false ,
3352
3360
/* prettyDebugInfo=*/ false ,
3353
3361
/* printGenericOpForm=*/ false ,
@@ -3363,11 +3371,12 @@ void mlir::python::populateIRCore(nb::module_ &m) {
3363
3371
nb::arg (" state" ), nb::arg (" file" ).none () = nb::none (),
3364
3372
nb::arg (" binary" ) = false , kOperationPrintStateDocstring )
3365
3373
.def (" print" ,
3366
- nb::overload_cast<std::optional<int64_t >, bool , bool , bool , bool ,
3367
- bool , bool , nb::object , bool , bool >(
3368
- &PyOperationBase::print),
3374
+ nb::overload_cast<std::optional<int64_t >, std::optional< int64_t > ,
3375
+ bool , bool , bool , bool , bool , bool , nb::object,
3376
+ bool , bool >( &PyOperationBase::print),
3369
3377
// Careful: Lots of arguments must match up with print method.
3370
3378
nb::arg (" large_elements_limit" ).none () = nb::none (),
3379
+ nb::arg (" large_resource_limit" ).none () = nb::none (),
3371
3380
nb::arg (" enable_debug_info" ) = false ,
3372
3381
nb::arg (" pretty_debug_info" ) = false ,
3373
3382
nb::arg (" print_generic_op_form" ) = false ,
@@ -3383,6 +3392,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
3383
3392
// Careful: Lots of arguments must match up with get_asm method.
3384
3393
nb::arg (" binary" ) = false ,
3385
3394
nb::arg (" large_elements_limit" ).none () = nb::none (),
3395
+ nb::arg (" large_resource_limit" ).none () = nb::none (),
3386
3396
nb::arg (" enable_debug_info" ) = false ,
3387
3397
nb::arg (" pretty_debug_info" ) = false ,
3388
3398
nb::arg (" print_generic_op_form" ) = false ,
0 commit comments