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

Add test_mlir_execution.py #1

Merged
merged 2 commits into from
Feb 29, 2024

Conversation

alexander-shaposhnikov
Copy link

Test plan: python3 -m pytest -s test/test_mlir_execution.py

@@ -17,7 +17,8 @@ def transform(self, value: Value) -> ir.Module:
with InsertionPoint(module.body):
@func.func()
def main():
return arith.fptosi(ir.IntegerType.get_signless(32), self.walk(value))
return self.walk(value)
Copy link
Owner

Choose a reason for hiding this comment

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

informational: originally i needed fptosi because i was returning it as the exit code.

transformed_mlir_module = transform(mlir_module)
print(transformed_mlir_module)
execution_engine = ExecutionEngine(transformed_mlir_module)
c_float_p = ctypes.c_float * 1
Copy link
Owner

Choose a reason for hiding this comment

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

What is this?

Copy link
Owner

Choose a reason for hiding this comment

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

ah pointer to an array of 1 float.

c_float_p = ctypes.c_float * 1
res = c_float_p(-1.0)
execution_engine.invoke("main", res)
print(res[0])
Copy link
Owner

Choose a reason for hiding this comment

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

yay!

@fzakaria
Copy link
Owner

Cool!
Did a first pass; will review more at home. I have to leave to pickup my son shortly

Copy link
Owner

@fzakaria fzakaria left a comment

Choose a reason for hiding this comment

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

I think subsequent changes we can wrap the PassManager in a JIT Engine class

@fzakaria fzakaria merged commit 67516d4 into fzakaria:master Feb 29, 2024
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