google / google/heir

WrapGeneric forces output to secret type, leading to crashes later in the pipeline

Open
#2,553 8 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

A program that does not actually return a secret value, e.g.,

```llvm
//RUN: heir-opt --mlir-to-bgv %s | FileCheck %s
func.func @foo(%x: i32 {secret.secret}) -> i8 {
%0 = arith.constant 42 : i8
func.return %0 : i8
}
```

crashes with the following:
```
// -----// IR Dump Before ConvertToCiphertextSemantics (convert-to-ciphertext-semantics) //----- //
#layout = #tensor_ext.layout<"{ [] -> [ct, slot] : ct = 0 and 0 <= slot <= 1023 }">
module {
func.func @foo(%arg0: !secret.secret {tensor_ext.layout = #layout}) -> (!secret.secret {tensor_ext.layout = #layout}) {
%c42_i8 = arith.constant 42 : i8
%0 = secret.conceal %c42_i8 : i8 -> !secret.secret
%1 = tensor_ext.assign_layout %0 {layout = #layout, tensor_ext.layout = #layout} : !secret.secret
return %1 : !secret.secret
}
}

tmp.mlir:2:1: error: unexpected unrealized conversion cast op found
func.func @foo(%x: i32 {secret.secret}) -> i8 {
^
tmp.mlir:2:1: note: see current operation: %3 = "builtin.unrealized_conversion_cast"(%2) : (tensor<1x1024x!secret.secret>) -> !secret.secret>
```

Obviously a bit of a pathological program, but this bug was encountered "in the wild" in #2525 (but unrelated to that frontend bug)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.