Skip to content

Commit 5a6890d

Browse files
committed
Docs add more test examples
1 parent 24c0a48 commit 5a6890d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/Transforms/OperationBalancer/OperationBalancer.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def OperationBalancer : Pass<"operation-balancer"> {
2828

2929
This pass was inspired by section 2.6 of ['EVA Improved: Compiler and Extension
3030
Library for CKKS' by Chowdhary et al](https://eprint.iacr.org/2021/1505).
31+
32+
(* example filepath=tests/Transforms/operation_balancer/doctest.mlir *)
3133
}];
3234
}
3335

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: heir-opt --operation-balancer %s | FileCheck %s
2+
3+
// CHECK: func.func @main(%arg0: !secret.secret<i32>, %arg1: !secret.secret<i32>, %arg2: !secret.secret<i32>, %arg3: !secret.secret<i32>, %arg4: !secret.secret<i32>) -> !secret.secret<i32> {
4+
// CHECK-NEXT: %0 = secret.generic(%arg0: !secret.secret<i32>, %arg1: !secret.secret<i32>, %arg2: !secret.secret<i32>, %arg3: !secret.secret<i32>, %arg4: !secret.secret<i32>) {
5+
// CHECK-NEXT: ^body(%input0: i32, %input1: i32, %input2: i32, %input3: i32, %input4: i32):
6+
// CHECK-NEXT: %1 = arith.addi %input0, %input1 : i32
7+
// CHECK-NEXT: %2 = arith.addi %input2, %input3 : i32
8+
// CHECK-NEXT: %3 = arith.addi %2, %input4 : i32
9+
// CHECK-NEXT: %4 = arith.addi %1, %3 : i32
10+
// CHECK-NEXT: secret.yield %4 : i32
11+
// CHECK-NEXT: } -> !secret.secret<i32>
12+
// CHECK-NEXT: return %0 : !secret.secret<i32>
13+
// CHECK-NEXT: }
14+
func.func @main(%arg0 : !secret.secret<i32>, %arg1 : !secret.secret<i32>, %arg2 : !secret.secret<i32>, %arg3 : !secret.secret<i32>, %arg4 : !secret.secret<i32>) -> !secret.secret<i32> {
15+
%0 = secret.generic(%arg0 : !secret.secret<i32>, %arg1 : !secret.secret<i32>, %arg2 : !secret.secret<i32>, %arg3 : !secret.secret<i32>, %arg4 : !secret.secret<i32>) {
16+
^body(%input0 : i32, %input1 : i32, %input2 : i32, %input3 : i32, %input4 : i32):
17+
%a = arith.addi %input0, %input1 : i32
18+
%b = arith.addi %a, %input2 : i32
19+
%c = arith.addi %b, %input3 : i32
20+
%d = arith.addi %c, %input4 : i32
21+
secret.yield %d : i32
22+
} -> !secret.secret<i32>
23+
return %0 : !secret.secret<i32>
24+
}

0 commit comments

Comments
 (0)