-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix secret-distribute-generic with multiple ops and secret loop-…
…carried vars Re-runs secretness analysis after each split If there is a secret loop-carried variable, the secretness analysis must be re-run after each split to ensure that the secretness state for a loop-carried variable is correct. Otherwise, after one operation is split from the generic, the generic is replaced and the secretness lattice doesn't think the loop-carried var (the yielded values from the loop) are secret. PiperOrigin-RevId: 721009497
- Loading branch information
1 parent
8f0bff7
commit 595fee3
Showing
3 changed files
with
53 additions
and
8 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
40 changes: 40 additions & 0 deletions
40
tests/Dialect/Secret/Transforms/secret_distribute_generic/distribute_generic_state.mlir
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,40 @@ | ||
// RUN: heir-opt --secret-distribute-generic %s | FileCheck %s | ||
|
||
// This tests a generic with multiple operations in its body, including a loop | ||
// with secret loop-carried variables. For this test, the secretness analysis | ||
// must have been re-run after each operation is split to ensure that the | ||
// secretness state for a loop-carried variable is correct. | ||
|
||
// CHECK-LABEL: test | ||
// CHECK-SAME: %[[arg0:.*]]: !secret.secret<tensor<1x1024xf32>>) -> !secret.secret<tensor<1x1024xf32>> { | ||
module { | ||
func.func @test(%arg0: !secret.secret<tensor<1x1024xf32>>) -> !secret.secret<tensor<1x1024xf32>> { | ||
// CHECK-DAG: %[[cst:.*]] = arith.constant | ||
// CHECK-DAG: %[[v0:.*]] = secret.conceal %[[cst]] : tensor<1x1024xf32> | ||
// CHECK-NEXT: %[[v1:.*]] = affine.for %[[i:.*]] = 0 to 1023 iter_args(%[[arg2:.*]] = %[[v0]]) -> (!secret.secret<tensor<1x1024xf32>>) { | ||
// CHECK-NEXT: %[[v3:.*]] = secret.generic ins(%[[arg0]], %[[arg2]] : !secret.secret<tensor<1x1024xf32>>, !secret.secret<tensor<1x1024xf32>>) { | ||
// CHECK-NEXT: ^body(%[[input0:.*]]: tensor<1x1024xf32>, %[[input1:.*]]: tensor<1x1024xf32>): | ||
// CHECK-NEXT: %[[v4:.*]] = arith.addf %[[input1]], %[[input0]] : tensor<1x1024xf32> | ||
// CHECK-NEXT: secret.yield %[[v4]] : tensor<1x1024xf32> | ||
// CHECK-NEXT: } -> !secret.secret<tensor<1x1024xf32>> | ||
// CHECK-NEXT: affine.yield %[[v3]] : !secret.secret<tensor<1x1024xf32>> | ||
// CHECK-NEXT: } | ||
// CHECK-NEXT: %[[v2:.*]] = secret.generic ins(%[[v1]] : !secret.secret<tensor<1x1024xf32>>) { | ||
// CHECK-NEXT: ^body(%[[input0:.*]]: tensor<1x1024xf32>): | ||
// CHECK-NEXT: %[[v3:.*]] = arith.addf %[[input0]], %[[input0]] : tensor<1x1024xf32> | ||
// CHECK-NEXT: secret.yield %[[v3]] : tensor<1x1024xf32> | ||
// CHECK-NEXT: } -> !secret.secret<tensor<1x1024xf32>> | ||
// CHECK-NEXT: return %[[v2]] : !secret.secret<tensor<1x1024xf32>> | ||
%cst_3 = arith.constant dense<0.000000e+00> : tensor<1x1024xf32> | ||
%0 = secret.generic ins(%arg0 : !secret.secret<tensor<1x1024xf32>>) { | ||
^body(%input0: tensor<1x1024xf32>): | ||
%1 = affine.for %arg1 = 0 to 1023 iter_args(%arg2 = %cst_3) -> (tensor<1x1024xf32>) { | ||
%9 = arith.addf %arg2, %input0 : tensor<1x1024xf32> | ||
affine.yield %9 : tensor<1x1024xf32> | ||
} | ||
%3 = arith.addf %1, %1 : tensor<1x1024xf32> | ||
secret.yield %3 : tensor<1x1024xf32> | ||
} -> !secret.secret<tensor<1x1024xf32>> | ||
return %0 : !secret.secret<tensor<1x1024xf32>> | ||
} | ||
} |
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