Skip to content

[mlir] Python: Extend print large elements limit to resources #125738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

nikalra
Copy link
Contributor

@nikalra nikalra commented Feb 4, 2025

If the large element limit is specified, large elements are hidden from the asm but large resources are not. This change extends the large elements limit to apply to printed resources as well.

If the large element limit is specified, large elements are hidden from the asm but large resources are not. This change extends the large elements limit to apply to printed resources as well.
@llvmbot
Copy link
Member

llvmbot commented Feb 4, 2025

@llvm/pr-subscribers-mlir

Author: Nikhil Kalra (nikalra)

Changes

If the large element limit is specified, large elements are hidden from the asm but large resources are not. This change extends the large elements limit to apply to printed resources as well.


Full diff: https://github.com/llvm/llvm-project/pull/125738.diff

1 Files Affected:

  • (modified) mlir/lib/Bindings/Python/IRCore.cpp (+3-1)
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index 8e351cb22eb948..47a85c2a486fd4 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1296,8 +1296,10 @@ void PyOperationBase::print(std::optional<int64_t> largeElementsLimit,
     fileObject = nb::module_::import_("sys").attr("stdout");
 
   MlirOpPrintingFlags flags = mlirOpPrintingFlagsCreate();
-  if (largeElementsLimit)
+  if (largeElementsLimit) {
     mlirOpPrintingFlagsElideLargeElementsAttrs(flags, *largeElementsLimit);
+    mlirOpPrintingFlagsElideLargeResourceString(flags, *largeElementsLimit);
+  }
   if (enableDebugInfo)
     mlirOpPrintingFlagsEnableDebugInfo(flags, /*enable=*/true,
                                        /*prettyForm=*/prettyDebugInfo);

@nikalra nikalra changed the title [mlir] Python: Extend print large elemnts limit to resources [mlir] Python: Extend print large elements limit to resources Feb 4, 2025
@makslevental
Copy link
Contributor

Seems reasonable - can you please add a test?

@nikalra
Copy link
Contributor Author

nikalra commented Feb 5, 2025

Seems reasonable - can you please add a test?

done!

Copy link
Contributor

@makslevental makslevental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool thanks - I actually needed this last year but never got around to it.

@nikalra nikalra merged commit 0ad1f83 into llvm:main Feb 5, 2025
8 checks passed
@nikalra nikalra deleted the large-resource-limit branch February 5, 2025 19:48
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
…25738)

If the large element limit is specified, large elements are hidden from
the asm but large resources are not. This change extends the large
elements limit to apply to printed resources as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants