Skip to content
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

[Backport release/1.5.x] Bug fix: printing non-distributed data #1764

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion heat/core/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ def _tensor_str(dndarray, indent: int) -> str:
# to do so, we slice up the torch data and forward it to torch internal printing mechanism
summarize = elements > get_printoptions()["threshold"]
torch_data = _torch_data(dndarray, summarize)
if not dndarray.is_distributed():
# let torch handle formatting on non-distributed data
# formatter gets too slow for even moderately large tensors
return torch._tensor_str._tensor_str(torch_data, indent)
formatter = torch._tensor_str._Formatter(torch_data)

return torch._tensor_str._tensor_str_with_formatter(torch_data, indent, summarize, formatter)
Loading