-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
secret-to-bgv: add lowering patterns for rotate and add hamming dista…
…nce example PiperOrigin-RevId: 617242491
- Loading branch information
1 parent
8cb01ed
commit fd9867b
Showing
6 changed files
with
84 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,33 @@ | ||
// RUN: heir-opt --secretize=entry-function=hamming --wrap-generic \ | ||
// RUN: --canonicalize --cse --heir-simd-vectorizer \ | ||
// RUN: --secret-distribute-generic --secret-to-bgv \ | ||
// RUN: %s | FileCheck %s | ||
|
||
// CHECK-LABEL: @hamming | ||
// CHECK: bgv.sub | ||
// CHECK-NEXT: bgv.mul | ||
// CHECK-NEXT: bgv.relinearize | ||
// CHECK-NEXT: bgv.rotate | ||
// CHECK-NEXT: bgv.add | ||
// CHECK-NEXT: bgv.rotate | ||
// CHECK-NEXT: bgv.add | ||
// CHECK-NEXT: bgv.add | ||
// CHECK-NEXT: bgv.extract | ||
// CHECK-NEXT: return | ||
|
||
func.func @hamming(%arg0: tensor<1024xi16>, %arg1: tensor<1024xi16>) -> i16 { | ||
%c0 = arith.constant 0 : index | ||
%c0_si16 = arith.constant 0 : i16 | ||
%0 = affine.for %arg2 = 0 to 1024 iter_args(%arg6 = %c0_si16) -> i16 { | ||
%1 = tensor.extract %arg0[%arg2] : tensor<1024xi16> | ||
%2 = tensor.extract %arg1[%arg2] : tensor<1024xi16> | ||
%3 = arith.subi %1, %2 : i16 | ||
%4 = tensor.extract %arg0[%arg2] : tensor<1024xi16> | ||
%5 = tensor.extract %arg1[%arg2] : tensor<1024xi16> | ||
%6 = arith.subi %4, %5 : i16 | ||
%7 = arith.muli %3, %6 : i16 | ||
%8 = arith.addi %arg6, %7 : i16 | ||
affine.yield %8 : i16 | ||
} | ||
return %0 : i16 | ||
} |
This file contains 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