@@ -97,6 +97,10 @@ static const char kOperationPrintDocstring[] =
9797 binary: Whether to write bytes (True) or str (False). Defaults to False.
9898 large_elements_limit: Whether to elide elements attributes above this
9999 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.
100104 enable_debug_info: Whether to print debug/location information. Defaults
101105 to False.
102106 pretty_debug_info: Whether to format debug information for easier reading
@@ -1303,6 +1307,7 @@ void PyOperation::checkValid() const {
13031307}
13041308
13051309void PyOperationBase::print (std::optional<int64_t > largeElementsLimit,
1310+ std::optional<int64_t > largeResourceLimit,
13061311 bool enableDebugInfo, bool prettyDebugInfo,
13071312 bool printGenericOpForm, bool useLocalScope,
13081313 bool useNameLocAsPrefix, bool assumeVerified,
@@ -1314,10 +1319,10 @@ void PyOperationBase::print(std::optional<int64_t> largeElementsLimit,
13141319 fileObject = nb::module_::import_ (" sys" ).attr (" stdout" );
13151320
13161321 MlirOpPrintingFlags flags = mlirOpPrintingFlagsCreate ();
1317- if (largeElementsLimit) {
1322+ if (largeElementsLimit)
13181323 mlirOpPrintingFlagsElideLargeElementsAttrs (flags, *largeElementsLimit);
1319- mlirOpPrintingFlagsElideLargeResourceString (flags, *largeElementsLimit);
1320- }
1324+ if (largeResourceLimit)
1325+ mlirOpPrintingFlagsElideLargeResourceString (flags, *largeResourceLimit);
13211326 if (enableDebugInfo)
13221327 mlirOpPrintingFlagsEnableDebugInfo (flags, /* enable=*/ true ,
13231328 /* prettyForm=*/ prettyDebugInfo);
@@ -1405,6 +1410,7 @@ void PyOperationBase::walk(
14051410
14061411nb::object PyOperationBase::getAsm (bool binary,
14071412 std::optional<int64_t > largeElementsLimit,
1413+ std::optional<int64_t > largeResourceLimit,
14081414 bool enableDebugInfo, bool prettyDebugInfo,
14091415 bool printGenericOpForm, bool useLocalScope,
14101416 bool useNameLocAsPrefix, bool assumeVerified,
@@ -1416,6 +1422,7 @@ nb::object PyOperationBase::getAsm(bool binary,
14161422 fileObject = nb::module_::import_ (" io" ).attr (" StringIO" )();
14171423 }
14181424 print (/* largeElementsLimit=*/ largeElementsLimit,
1425+ /* largeResourceLimit=*/ largeResourceLimit,
14191426 /* enableDebugInfo=*/ enableDebugInfo,
14201427 /* prettyDebugInfo=*/ prettyDebugInfo,
14211428 /* printGenericOpForm=*/ printGenericOpForm,
@@ -3348,6 +3355,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
33483355 [](PyOperationBase &self) {
33493356 return self.getAsm (/* binary=*/ false ,
33503357 /* largeElementsLimit=*/ std::nullopt ,
3358+ /* largeResourceLimit=*/ std::nullopt ,
33513359 /* enableDebugInfo=*/ false ,
33523360 /* prettyDebugInfo=*/ false ,
33533361 /* printGenericOpForm=*/ false ,
@@ -3363,11 +3371,12 @@ void mlir::python::populateIRCore(nb::module_ &m) {
33633371 nb::arg (" state" ), nb::arg (" file" ).none () = nb::none (),
33643372 nb::arg (" binary" ) = false , kOperationPrintStateDocstring )
33653373 .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),
33693377 // Careful: Lots of arguments must match up with print method.
33703378 nb::arg (" large_elements_limit" ).none () = nb::none (),
3379+ nb::arg (" large_resource_limit" ).none () = nb::none (),
33713380 nb::arg (" enable_debug_info" ) = false ,
33723381 nb::arg (" pretty_debug_info" ) = false ,
33733382 nb::arg (" print_generic_op_form" ) = false ,
@@ -3383,6 +3392,7 @@ void mlir::python::populateIRCore(nb::module_ &m) {
33833392 // Careful: Lots of arguments must match up with get_asm method.
33843393 nb::arg (" binary" ) = false ,
33853394 nb::arg (" large_elements_limit" ).none () = nb::none (),
3395+ nb::arg (" large_resource_limit" ).none () = nb::none (),
33863396 nb::arg (" enable_debug_info" ) = false ,
33873397 nb::arg (" pretty_debug_info" ) = false ,
33883398 nb::arg (" print_generic_op_form" ) = false ,
0 commit comments