Skip to content

Adds generic log to the math dialect#633

Open
aadi07 wants to merge 4 commits intoQuEraComputing:mainfrom
aadi07:aadi/fix-math-log-signature-fallback
Open

Adds generic log to the math dialect#633
aadi07 wants to merge 4 commits intoQuEraComputing:mainfrom
aadi07:aadi/fix-math-log-signature-fallback

Conversation

@aadi07
Copy link
Copy Markdown

@aadi07 aadi07 commented Apr 4, 2026

Fixes #131 - however the issue was caused by inspect.signature throwing a value error when the function passed in has variable arguments (in the case of math.log, the base argument is optional). I've bypassed this by forcing the log to have a base passed in. Not sure this is ideal for the use case here (could be preferable to default to the natural log). Open to any suggestions.

@aadi07
Copy link
Copy Markdown
Author

aadi07 commented Apr 4, 2026

When I ran _gen.py under the math dialect, it edited what were formerly references to "lowering" to "lowering2" - it seems to have been an intentional change based on the commit history, but it doesn't seem to be properly recognized, so I also wanted to verify if this was intended or should be kept as lowering?

@kaihsin
Copy link
Copy Markdown
Collaborator

kaihsin commented Apr 5, 2026

When I ran _gen.py under the math dialect, it edited what were formerly references to "lowering" to "lowering2" - it seems to have been an intentional change based on the commit history, but it doesn't seem to be properly recognized, so I also wanted to verify if this was intended or should be kept as lowering?

@aadi07 I think this need to update too. there should be only "lowering" exists now.

@aadi07
Copy link
Copy Markdown
Author

aadi07 commented Apr 5, 2026

Got it, that change should be reflected now as well. Does everything else look good?

@lowering.wraps(stmts.trunc)
def trunc(x: float) -> int: ...

def trunc(x: int) -> int: ...
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same here

Comment on lines +113 to +117
@impl(stmts.fma)
def fma(self, interp, frame: Frame, stmt: stmts.fma):
values = frame.get_values(stmt.args)
return (math.fma(values[0], values[1], values[2]),)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

please remove fma from this PR. it only support on 3.13+

@kaihsin
Copy link
Copy Markdown
Collaborator

kaihsin commented Apr 5, 2026 via email

@aadi07
Copy link
Copy Markdown
Author

aadi07 commented Apr 6, 2026

I think the latest commit should have resolved this. I've added fma to the excepted functions list, and made sure that all input parameters are encoded as floats by default, with only the outputs varying appropriately.

@kaihsin
Copy link
Copy Markdown
Collaborator

kaihsin commented Apr 7, 2026

@aadi07 can you fix the linting issue? you can use pre-commit tool to do that for you

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

Missing log in math dialect.

2 participants