-
Notifications
You must be signed in to change notification settings - Fork 15
add support of neura.PhiOp in interpreter #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // RUN: neura-interpreter %s | FileCheck %s | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we run mlir-neura-opt with |
||
| module { | ||
| func.func @test_phi() -> f32 { | ||
| %true_path_val = "neura.constant"() <{ | ||
| value = 10.0 : f32, | ||
| predicate = true | ||
| }> : () -> f32 | ||
|
|
||
| %false_path_val = "neura.constant"() <{ | ||
| value = 20.0 : f32, | ||
| predicate = false | ||
| }> : () -> f32 | ||
|
|
||
| %result = "neura.phi"(%true_path_val, %false_path_val) : (f32, f32) -> f32 | ||
|
|
||
| return %result : f32 | ||
| // CHECK: [neura-interpreter] Output: 10.000000 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,6 +95,17 @@ int main(int argc, char **argv) { | |
|
|
||
| valueMap[constOp.getResult()] = val; | ||
|
|
||
| } else if (auto phiOp = dyn_cast<neura::PhiOp>(op)) { | ||
| PredicatedData result{0.0f, false}; // Default to a false predicate. | ||
| // Find the one operand with a true predicate. | ||
| for (Value operand : phiOp.getOperands()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Plz hold on, let me re-think the design. Its current form cannot support the diagram shown in README: https://github.com/tancheng/CGRA-Mapper
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I introduced Later on, we can introduce new op to fuse the ( |
||
| auto incoming = valueMap[operand]; | ||
| if (incoming.predicate) { | ||
| result = incoming; | ||
| break; // Found the active value. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the comment above the |
||
| } | ||
| } | ||
| valueMap[phiOp.getResult()] = result; | ||
| } else if (auto movOp = dyn_cast<neura::DataMovOp>(op)) { | ||
| valueMap[movOp.getResult()] = valueMap[movOp.getOperand()]; | ||
|
|
||
|
|
||
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.
Rename the test as
phi_interpret.mlir.