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

only break long lines in unpacking #42

Merged
merged 5 commits into from
Mar 23, 2024
Merged
Changes from 1 commit
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
35 changes: 26 additions & 9 deletions thunder/core/prims.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,12 +754,20 @@ def unpack_sequence_printer(
if len(bsym.output) == 0:
t-vi marked this conversation as resolved.
Show resolved Hide resolved
return f"# {call_str} (empty sequence)"

lines = []
for out in out_printables:
line = f"{codeutils.prettyprint(out, literals_as_underscores=True)}, \\"
lines.append(line)
parts = [f"{codeutils.prettyprint(out, literals_as_underscores=True)}, " for out in out_printables]
parts.append(f"= {call_str}")

lines.append(f"= {call_str}")
lines = []
line_parts = []
pos = 0
for p in parts:
if pos and pos + len(p) > 80:
lines.append("".join(line_parts) + " \\")
t-vi marked this conversation as resolved.
Show resolved Hide resolved
line_parts = []
line_parts.append(p)
pos += len(p)

lines.append("".join(line_parts))
return lines


Expand Down Expand Up @@ -812,12 +820,21 @@ def _unpack_tuple_printer(
if len(bsym.output) == 0:
return f"# {call_str} (empty tuple)"

parts = [f"{codeutils.prettyprint(out, literals_as_underscores=True)}, " for out in out_printables]
t-vi marked this conversation as resolved.
Show resolved Hide resolved
parts.append(f"= {call_str}")

lines = []
for out in out_printables:
line = f"{codeutils.prettyprint(out, literals_as_underscores=True)}, \\"
lines.append(line)
line_parts = []
pos = 0
for p in parts:
if pos and pos + len(p) > 80:
lines.append("".join(line_parts) + " \\")
line_parts = []
line_parts.append(p)
pos += len(p)

lines.append("".join(line_parts))

lines.append(f"= {call_str}")
return lines


Expand Down
Loading