Skip to content

Commit 28549ef

Browse files
committed
Bump LLVM pin to 0f3ca6bb9ca514518c55fc02855a6083312ddfe2 and migrate to the new MLIR complex element type API. LLVM commit 0ff5c32c2821 ("[mlir] Use custom mlir::Complex type for non-float complex numbers") changed the `DenseElementsAttr::get` and `SplatElementsAttr::get` complex overloads to take `ArrayRef<mlir::Complex<T>>` instead of `ArrayRef<std::complex<T>>`. For `T = APFloat`/`APInt`, `mlir::Complex<T>` resolves to `NonFloatComplex<T>` since neither type satisfies `std::is_floating_point_v`. The two existing call sites that constructed `std::complex<APFloat>` for these helpers no longer compile. Replace `std::complex<APFloat>` with `mlir::Complex<APFloat>` at the call sites that feed `DenseElementsAttr::get` / `SplatElementsAttr::get`.
1 parent 4313da9 commit 28549ef

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎build_tools/llvm_version.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7189c4bb83d90c383741a9480fceca9c7bf74b27
1+
0f3ca6bb9ca514518c55fc02855a6083312ddfe2

‎stablehlo/reference/Tensor.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,8 @@ Tensor makeTensor(DenseElementsAttr attr) {
539539
auto complexElemTy = cast<ComplexType>(elementType).getElementType();
540540
if (complexElemTy.isF32()) {
541541
auto complexValues = llvm::map_to_vector(
542-
attr.getValues<std::complex<APFloat>>(),
543-
[&](std::complex<APFloat> value) -> std::complex<float> {
542+
attr.getValues<mlir::Complex<APFloat>>(),
543+
[&](mlir::Complex<APFloat> value) -> std::complex<float> {
544544
return std::complex<float>(value.real().convertToFloat(),
545545
value.imag().convertToFloat());
546546
});
@@ -551,8 +551,8 @@ Tensor makeTensor(DenseElementsAttr attr) {
551551
}
552552
if (complexElemTy.isF64()) {
553553
auto complexValues = llvm::map_to_vector(
554-
attr.getValues<std::complex<APFloat>>(),
555-
[&](std::complex<APFloat> value) -> std::complex<double> {
554+
attr.getValues<mlir::Complex<APFloat>>(),
555+
[&](mlir::Complex<APFloat> value) -> std::complex<double> {
556556
return std::complex<double>(value.real().convertToDouble(),
557557
value.imag().convertToDouble());
558558
});

‎stablehlo/transforms/StablehloLegalizeDeprecatedOps.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ DenseElementsAttr getScalarOfType(Type ty, int64_t rawValue) {
126126
APFloat real(floatTy.getFloatSemantics(), rawValue);
127127
APFloat imag = APFloat::getZero(floatTy.getFloatSemantics());
128128
return DenseElementsAttr::get(scalarTy,
129-
std::complex<APFloat>(real, imag));
129+
mlir::Complex<APFloat>(real, imag));
130130
}
131131
}
132132
llvm::report_fatal_error("unsupported type");

‎stablehlo/transforms/optimization/StablehloAggressiveFolder.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class LazyPlaceholderValue {
112112
bool losesInfo;
113113
apFloatZero.convert(realImagComponentFloatType.getFloatSemantics(),
114114
llvm::RoundingMode::NearestTiesToEven, &losesInfo);
115-
std::complex<APFloat> complexZeroScalar(apFloatZero, apFloatZero);
115+
mlir::Complex<APFloat> complexZeroScalar(apFloatZero, apFloatZero);
116116
auto complexZeroSplat =
117117
SplatElementsAttr::get(shapedType, complexZeroScalar);
118118
return LazyPlaceholderValue(

0 commit comments

Comments
 (0)