mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
fix(compiler): Fix lowering of tensor.from_elements with crt
This commit is contained in:
@@ -777,6 +777,8 @@ struct FromElementsOpPattern
|
||||
if (converter.isLegal(resultTy)) {
|
||||
return mlir::failure();
|
||||
}
|
||||
auto oldTensorResultTy = resultTy.cast<mlir::RankedTensorType>();
|
||||
auto oldRank = oldTensorResultTy.getRank();
|
||||
|
||||
auto newTensorResultTy =
|
||||
converter.convertType(resultTy).cast<mlir::RankedTensorType>();
|
||||
@@ -786,11 +788,12 @@ struct FromElementsOpPattern
|
||||
mlir::Value tensor = rewriter.create<mlir::bufferization::AllocTensorOp>(
|
||||
fromElementsOp.getLoc(), newTensorResultTy, mlir::ValueRange{});
|
||||
|
||||
// sizes are [1, ..., 1, lweSize]
|
||||
llvm::SmallVector<mlir::OpFoldResult> sizes(newRank - 1,
|
||||
// sizes are [1, ..., 1, diffShape...]
|
||||
llvm::SmallVector<mlir::OpFoldResult> sizes(oldRank,
|
||||
rewriter.getI64IntegerAttr(1));
|
||||
sizes.push_back(
|
||||
rewriter.getI64IntegerAttr(*(newTensorResultTy.getShape().end() - 1)));
|
||||
for (auto i = newRank - oldRank; i > 0; i--) {
|
||||
sizes.push_back(rewriter.getI64IntegerAttr(*(newShape.end() - i)));
|
||||
}
|
||||
|
||||
// strides are [1, ..., 1]
|
||||
llvm::SmallVector<mlir::OpFoldResult> oneStrides(
|
||||
|
||||
8
compiler/tests/check_tests/BugReport/bug_report_785.mlir
Normal file
8
compiler/tests/check_tests/BugReport/bug_report_785.mlir
Normal file
@@ -0,0 +1,8 @@
|
||||
// RUN: concretecompiler --action=dump-llvm-ir %s
|
||||
// Just ensure that compile
|
||||
// https://github.com/zama-ai/concrete-compiler-internal/issues/785
|
||||
func.func @main(%arg0: !FHE.eint<15>, %cst: tensor<32768xi64>) -> tensor<1x!FHE.eint<15>> {
|
||||
%1 = "FHE.apply_lookup_table"(%arg0, %cst) : (!FHE.eint<15>, tensor<32768xi64>) -> !FHE.eint<15>
|
||||
%6 = tensor.from_elements %1 : tensor<1x!FHE.eint<15>> // ERROR HERE line 4
|
||||
return %6 : tensor<1x!FHE.eint<15>>
|
||||
}
|
||||
Reference in New Issue
Block a user