-
Notifications
You must be signed in to change notification settings - Fork 15
add interpreter dataflow mode #105
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c48566c
add interpreter dataflow mode
30c0c82
add interpreter dataflow mode
0305dc9
add interpreter dataflow mode
2f3a9f3
add interpreter dataflow mode
7627287
add interpreter dataflow mode
ca864d2
add interpreter dataflow mode
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,30 @@ | ||
| // RUN: neura-interpreter %s | FileCheck %s | ||
| // RUN: neura-interpreter %s --verbose | FileCheck %s | ||
|
|
||
| // Test 1: Bitwise NOT of 42 (result should be -43) | ||
| func.func @test_not_basic() -> i32 { | ||
| func.func @test_not_nonzero() -> i32 { | ||
| %a = arith.constant 42 : i32 | ||
| %res = "neura.not"(%a) : (i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: -43.000000 | ||
| // CHECK: [neura-interpreter] → Output: 0.000000 | ||
| return %res : i32 | ||
| } | ||
|
|
||
| // Test 2: Bitwise NOT of 0 (result should be -1) | ||
| func.func @test_not_zero() -> i32 { | ||
| %a = arith.constant 0 : i32 | ||
| %res = "neura.not"(%a) : (i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: -1.000000 | ||
| // CHECK: [neura-interpreter] → Output: 1.000000 | ||
| return %res : i32 | ||
| } | ||
|
|
||
| func.func @test_not_negative() -> i32 { | ||
| %a = arith.constant -1 : i32 | ||
| %res = "neura.not"(%a) : (i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: 0.000000 | ||
| return %res : i32 | ||
| } | ||
|
|
||
| // Test 3: Bitwise NOT of 1 (result should be -2) | ||
| func.func @test_not_one() -> i32 { | ||
| %a = arith.constant 1 : i32 | ||
| %res = "neura.not"(%a) : (i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: -2.000000 | ||
| // CHECK: [neura-interpreter] → Output: 0.000000 | ||
| return %res : i32 | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,39 @@ | ||
| // RUN: neura-interpreter %s | FileCheck %s | ||
| // RUN: neura-interpreter %s --verbose | FileCheck %s | ||
|
|
||
| // ====== Bitwise OR Operation Tests ====== | ||
| // ====== Logical OR Operation Tests ====== | ||
|
|
||
| // Case 1: 42 | 5 = 47 | ||
| func.func @test_or_basic() -> i32 { | ||
| %a = arith.constant 42 : i32 | ||
| %b = arith.constant 5 : i32 | ||
| // Case 1: true | true = true (1 || 1 = 1) | ||
| func.func @test_or_basic_true_true() -> i32 { | ||
| %a = arith.constant 1 : i32 // true (non-zero) | ||
| %b = arith.constant 1 : i32 // true (non-zero) | ||
| %res = "neura.or"(%a, %b) : (i32, i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: 47.000000 | ||
| // CHECK: [neura-interpreter] → Output: 1.000000 | ||
| return %res : i32 | ||
| } | ||
|
|
||
| // Case 2: OR with zero, should return original number | ||
| func.func @test_or_with_zero() -> i32 { | ||
| %a = arith.constant 123 : i32 | ||
| %b = arith.constant 0 : i32 | ||
| // Case 2: true | false = true (1 || 0 = 1) | ||
| func.func @test_or_true_false() -> i32 { | ||
| %a = arith.constant 1 : i32 // true | ||
| %b = arith.constant 0 : i32 // false | ||
| %res = "neura.or"(%a, %b) : (i32, i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: 123.000000 | ||
| // CHECK: [neura-interpreter] → Output: 1.000000 | ||
| return %res : i32 | ||
| } | ||
|
|
||
| // Case 3: Self OR, result should equal input | ||
| func.func @test_or_self() -> i32 { | ||
| %a = arith.constant 77 : i32 | ||
| %res = "neura.or"(%a, %a) : (i32, i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: 77.000000 | ||
| // Case 3: false | true = true (0 || 5 = 1) | ||
| func.func @test_or_false_true() -> i32 { | ||
| %a = arith.constant 0 : i32 // false | ||
| %b = arith.constant 5 : i32 // true (non-zero) | ||
| %res = "neura.or"(%a, %b) : (i32, i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: 1.000000 | ||
| return %res : i32 | ||
| } | ||
|
|
||
| // Case 4: OR with -1 (all bits set), should return -1 | ||
| func.func @test_or_with_minus_one() -> i32 { | ||
| %a = arith.constant 123 : i32 | ||
| %b = arith.constant -1 : i32 | ||
| // Case 4: false | false = false (0 || 0 = 0) | ||
| func.func @test_or_false_false() -> i32 { | ||
| %a = arith.constant 0 : i32 // false | ||
| %b = arith.constant 0 : i32 // false | ||
| %res = "neura.or"(%a, %b) : (i32, i32) -> i32 | ||
| // CHECK: [neura-interpreter] → Output: -1.000000 | ||
| // CHECK: [neura-interpreter] → Output: 0.000000 | ||
| return %res : i32 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tancheng marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // RUN: neura-interpreter %s --verbose --dataflow | FileCheck %s | ||
|
|
||
| func.func @loop_test() -> f32 attributes {accelerator = "neura"} { | ||
| %0 = "neura.grant_once"() <{constant_value = 10 : i64}> : () -> !neura.data<i64, i1> | ||
| %1 = "neura.grant_once"() <{constant_value = 0 : i64}> : () -> !neura.data<i64, i1> | ||
| %2 = "neura.grant_once"() <{constant_value = 1 : i64}> : () -> !neura.data<i64, i1> | ||
| %3 = "neura.grant_once"() <{constant_value = 3.000000e+00 : f32}> : () -> !neura.data<f32, i1> | ||
| %4 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> : () -> !neura.data<f32, i1> | ||
| %5 = "neura.reserve"() : () -> (!neura.data<i64, i1>) | ||
| %6 = "neura.phi"(%5, %0) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1> | ||
| %7 = "neura.reserve"() : () -> (!neura.data<i64, i1>) | ||
| %8 = "neura.phi"(%7, %2) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1> | ||
| %9 = "neura.reserve"() : () -> (!neura.data<f32, i1>) | ||
| %10 = "neura.phi"(%9, %3) : (!neura.data<f32, i1>, !neura.data<f32, i1>) -> !neura.data<f32, i1> | ||
| %11 = "neura.reserve"() : () -> (!neura.data<f32, i1>) | ||
| %12 = "neura.phi"(%11, %4) : (!neura.data<f32, i1>, !neura.data<f32, i1>) -> !neura.data<f32, i1> | ||
| %13 = "neura.reserve"() : () -> (!neura.data<i64, i1>) | ||
| %14 = "neura.phi"(%13, %1) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1> | ||
| %15 = "neura.fadd"(%12, %10) : (!neura.data<f32, i1>, !neura.data<f32, i1>) -> !neura.data<f32, i1> | ||
| %16 = "neura.add"(%14, %8) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i64, i1> | ||
| %17 = "neura.icmp"(%16, %6) <{cmpType = "slt"}> : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> !neura.data<i1, i1> | ||
| %18 = "neura.grant_predicate"(%16, %17) : (!neura.data<i64, i1>, !neura.data<i1, i1>) -> !neura.data<i64, i1> | ||
| "neura.ctrl_mov"(%18, %13) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> () | ||
| %19 = "neura.grant_predicate"(%15, %17) : (!neura.data<f32, i1>, !neura.data<i1, i1>) -> !neura.data<f32, i1> | ||
| "neura.ctrl_mov"(%19, %11) : (!neura.data<f32, i1>, !neura.data<f32, i1>) -> () | ||
| %20 = "neura.grant_predicate"(%3, %17) : (!neura.data<f32, i1>, !neura.data<i1, i1>) -> !neura.data<f32, i1> | ||
| "neura.ctrl_mov"(%20, %9) : (!neura.data<f32, i1>, !neura.data<f32, i1>) -> () | ||
| %21 = "neura.grant_predicate"(%2, %17) : (!neura.data<i64, i1>, !neura.data<i1, i1>) -> !neura.data<i64, i1> | ||
| "neura.ctrl_mov"(%21, %7) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> () | ||
| %22 = "neura.grant_predicate"(%0, %17) : (!neura.data<i64, i1>, !neura.data<i1, i1>) -> !neura.data<i64, i1> | ||
| "neura.ctrl_mov"(%22, %5) : (!neura.data<i64, i1>, !neura.data<i64, i1>) -> () | ||
| %23 = "neura.not"(%17) : (!neura.data<i1, i1>) -> !neura.data<i1, i1> | ||
| %24 = "neura.grant_predicate"(%15, %23) : (!neura.data<f32, i1>, !neura.data<i1, i1>) -> !neura.data<f32, i1> | ||
|
|
||
| // CHECK: [neura-interpreter] │ └─30.000000, [pred = 1] | ||
|
|
||
| "neura.return"(%24) : (!neura.data<f32, i1>) -> () | ||
| } |
tancheng marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.