Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/add.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// ===----------------------------------------------------------------------===//
// Test 1: Add two float constants
Expand Down
4 changes: 2 additions & 2 deletions test/neura/interpreter/basic_operation/br.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_br_with_args() -> i32 {
%0 = "neura.constant"() {value = 42 : i32} : () -> i32
Expand All @@ -16,6 +16,6 @@ func.func @test_br_with_multi_args() {

^bb1(%a: i32, %b: f32):
"neura.add"(%a, %a) : (i32, i32) -> i32
// CHECK-NEXT: [neura-interpreter] → Output: (void)
// CHECK: [neura-interpreter] → Output: (void)
return
}
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/cast.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// int -> float
func.func @test_cast_i2f() -> f32 {
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/cond_br.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_cond_br_true() {
%cond = arith.constant 1 : i1
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/ctrl_mov.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_ctrl_mov_basic() {
%a = "neura.reserve"() : () -> (i32)
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fadd.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// ===----------------------------------------------------------------------===//
// Test 1: Valid neura.fadd with positive constants
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fadd_fadd.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// Test basic fused fadd operation: (2.5 + 1.5) + 3.0 = 7.0
func.func @test_fadd_fadd_basic() -> f32 {
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fcmp.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// ====== Equal comparison (eq) ======
func.func @test_fcmp_eq_true() -> i1 {
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fdiv.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_fdiv_positive() -> f32 {
%a = arith.constant 10.0 : f32
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fmul.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// ===----------------------------------------------------------------------===//
// Test 1: Valid neura.fmul with positive constants
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fmul_add.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// (2.0 * 3.0) + 4.0 = 10.0
func.func @test_fmul_fadd_basic() -> f32 {
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/fsub.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// ===----------------------------------------------------------------------===//
// Test 1: Valid neura.fsub with positive constants
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/grant.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_grant_predicate() -> vector<4xf32> {
%val = "neura.constant"() {
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/icmp.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// ====== Equal comparison (eq) ======
// Positive case: Equal numbers
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/load_store.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_store_load_i32() -> i32 {
%addr = arith.constant 0 : i32
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

module {
// Test case: float (f32) load/store with single index
Expand Down
23 changes: 14 additions & 9 deletions test/neura/interpreter/basic_operation/not.mlir
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
}
}

45 changes: 23 additions & 22 deletions test/neura/interpreter/basic_operation/or.mlir
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
}
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/phi.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

//===----------------------------------------------------------------------===//
// Test 1: Basic Phi node with control flow
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/reserve.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_reserve_basic() {
%a = "neura.reserve"() : () -> (i32)
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/sel.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_sel_with_comparison() -> f32 {
%a = arith.constant 5.0 : f32
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/sub.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

// Test basic subtraction with positive result
func.func @test_sub_positive() -> i32 {
Expand Down
2 changes: 1 addition & 1 deletion test/neura/interpreter/basic_operation/vfmul.mlir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: neura-interpreter %s | FileCheck %s
// RUN: neura-interpreter %s --verbose | FileCheck %s

func.func @test_vfmul_basic() -> vector<2xf32> {
%a = "neura.constant"() {value = dense<[2.0, 3.0]> : vector<2xf32>} : () -> vector<2xf32>
Expand Down
38 changes: 38 additions & 0 deletions test/neura/interpreter/loop_dataflow.mlir
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>) -> ()
}
4 changes: 2 additions & 2 deletions test/neura/interpreter/lower_and_interpret.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ module {
%arg0 = arith.constant 9.0 : f32
%cst = arith.constant 2.0 : f32
%0 = arith.addf %arg0, %cst : f32
// CHECK: Golden output: [[OUTPUT:[0-9]+\.[0-9]+]]
// CHECK: [neura-interpreter] → Output: [[OUTPUT]]
// // CHECK: Golden output: [[OUTPUT:[0-9]+\.[0-9]+]]
// // CHECK: [neura-interpreter] → Output: [[OUTPUT]]
return %0 : f32
}
}
Expand Down
Loading