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

[OM] Add C API and Python bindings for EvaluatorValue::Reference. #6785

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

mikeurbach
Copy link
Contributor

In some OM dialect constructs, it is possible to receive EvaluatorValue::Reference values. In the Python bindings, where we are converting an EvaluatorValue to a Python value, we need to dereference the Reference, to get at the underlying EvaluatorValue that was set during evaluation.

This adds the necessary C APIs, and updates the Python bindings to use them. If we encounter a Reference, we dereference it and recursively call the converter function.

A Python test was added using an example IR from the Evaluator unit tests, which delays evaluation and introduces references.

In some OM dialect constructs, it is possible to receive
EvaluatorValue::Reference values. In the Python bindings, where we are
converting an EvaluatorValue to a Python value, we need to dereference
the Reference, to get at the underlying EvaluatorValue that was set
during evaluation.

This adds the necessary C APIs, and updates the Python bindings to use
them. If we encounter a Reference, we dereference it and recursively
call the converter function.

A Python test was added using an example IR from the Evaluator unit
tests, which delays evaluation and introduces references.
include/circt-c/Dialect/OM.h Outdated Show resolved Hide resolved
@mikeurbach mikeurbach force-pushed the mikeurbach/om-reference-bindings branch from 98c837e to 4762615 Compare March 5, 2024 21:24
@mikeurbach mikeurbach merged commit 675716b into main Mar 5, 2024
4 checks passed
@mikeurbach mikeurbach deleted the mikeurbach/om-reference-bindings branch March 5, 2024 22:49
Copy link
Member

@uenoku uenoku left a comment

Choose a reason for hiding this comment

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

It looks good but I didn't expect reference values are exposed to outside of evaluation... Evaluator::finalize was meant to eliminate intermediate reference values from values. I don't block but I'll take a look what's going there, thank you for catching this!

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.

3 participants