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

bug[next]: Fix gtfn code generation for negative literals #1511

Merged
merged 3 commits into from
Mar 22, 2024

Conversation

tehrengruber
Copy link
Contributor

@tehrengruber tehrengruber commented Mar 21, 2024

Add an extra space between the operators of BinOp such that minus(1, -1) does not get translated into 1--1, but 1 - -1.

While looking at that part of the code I was wondering whether there is another bug in that function namely that we don't case int32 literals to the respective C++ type.

I would add tests, but there seems to be no infrastructure for this. Should we leave it like that for now?

Copy link
Contributor

@havogt havogt left a comment

Choose a reason for hiding this comment

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

To keep code more readable, I'd go for adding a space in the BinaryExpr instead

src/gt4py/next/program_processors/codegens/gtfn/codegen.py Outdated Show resolved Hide resolved
case _:
return node.value
result = node.value
if node.type in ["bool", "int32", "int64", "float32", "float64"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can just make sure that there is a space in the binary operations? 1 - -1 should be ok

BinaryExpr = as_fmt("({lhs} {op} {rhs})")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much nicer. Thanks.

@tehrengruber tehrengruber merged commit d5eccd6 into main Mar 22, 2024
31 checks passed
@havogt havogt deleted the fix_gtfn_codegen_for_literals branch June 25, 2024 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants