-
Notifications
You must be signed in to change notification settings - Fork 404
fix: guard eaglerinliner with detecting a valid circuit #9025
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
fix: guard eaglerinliner with detecting a valid circuit #9025
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding and fixing this!
| nlaTable = std::make_unique<NLATable>(op); | ||
| CircuitOp circuit; | ||
| for (auto &topLevelOp : *op.getBody()) | ||
| if ((circuit = dyn_cast<CircuitOp>(topLevelOp))) | ||
| break; | ||
|
|
||
| if (circuit) | ||
| nlaTable = std::make_unique<NLATable>(circuit.getOperation()); | ||
| else | ||
| nlaTable.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could create a dense map of multiple NLATables, one for each circuit. That would allow us to run this reduction on inputs with multiple circuit ops. Maybe something like this works:
nlaTables.clear();
for (auto circuit : op.getOps<CircuitOp>())
nlaTables.insert({circuit, std::make_unique<NLATable>(circuit)});We could then define the tables using a map instead of a single unique pointer:
DenseMap<CircuitOp, std::unique_ptr<NLATable>> nlaTables;And inside the reduction when we need the NLATable, we can look it up using the local circuit:
auto &nlaTable = nlaTables.lookup(op.getParentOfType<CircuitOp>());
if (!nlaTable)
return 0;What do you think about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I'll implement your suggestions and test it on my local setup :)
Addressing feedback from Fabian Signed-off-by: Tianrui Wei <[email protected]>
4d30174 to
25ef9ab
Compare
|
@fabianschuiki Sorry for the delay in response, I've had a little trouble getting it to work properly. Let me know if you have any othe rsuggestions :) |
fabianschuiki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Sorry for taking so long to get back to this!
A crash could as here NLATable assumes each module always contains a CircuitOp. However, this assumption might not be valid as the reduction process goes on. This commit adds a guard to check for a circuit before creating the NLATable or skipping inlining when no circuit exists.
A corresponding stach trace (which this PR fixes)