Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update llvm-project to llvm/llvm-project@01d233ff403823389f848 #3011

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/BuildOnLinuxOSX.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash
git clone -n https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX-MLIR.
cd llvm-project && git checkout 00128a20eec27246719d73ba427bf821883b00b4 && cd ..
cd llvm-project && git checkout 01d233ff403823389f8480897e41aea84ecbb3d3 && cd ..
```

[same-as-file]: <> (utils/build-mlir.sh)
Expand Down
2 changes: 1 addition & 1 deletion docs/BuildOnWindows.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Install MLIR (as a part of LLVM-Project):
```shell
git clone -n https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX-MLIR.
cd llvm-project && git checkout 00128a20eec27246719d73ba427bf821883b00b4 && cd ..
cd llvm-project && git checkout 01d233ff403823389f8480897e41aea84ecbb3d3 && cd ..
```

[same-as-file]: <> (utils/build-mlir.cmd)
Expand Down
10 changes: 4 additions & 6 deletions src/Conversion/KrnlToAffine/ConvertKrnlToAffine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,20 +814,18 @@ AffineTypeConverter::AffineTypeConverter() {
addConversion([](Type type) { return type; });

addSourceMaterialization([&](OpBuilder &builder, Type resultType,
ValueRange inputs,
Location loc) -> std::optional<Value> {
ValueRange inputs, Location loc) -> Value {
if (inputs.size() != 1)
return std::nullopt;
return Value();

return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
.getResult(0);
});

addTargetMaterialization([&](OpBuilder &builder, Type resultType,
ValueRange inputs,
Location loc) -> std::optional<Value> {
ValueRange inputs, Location loc) -> Value {
if (inputs.size() != 1)
return std::nullopt;
return Value();

return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
.getResult(0);
Expand Down
10 changes: 4 additions & 6 deletions src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,20 +547,18 @@ KrnlTypeConverter::KrnlTypeConverter() {
});

addSourceMaterialization([&](OpBuilder &builder, Type resultType,
ValueRange inputs,
Location loc) -> std::optional<Value> {
ValueRange inputs, Location loc) -> Value {
if (inputs.size() != 1)
return std::nullopt;
return Value();

return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
.getResult(0);
});

addTargetMaterialization([&](OpBuilder &builder, Type resultType,
ValueRange inputs,
Location loc) -> std::optional<Value> {
ValueRange inputs, Location loc) -> Value {
if (inputs.size() != 1)
return std::nullopt;
return Value();

return builder.create<UnrealizedConversionCastOp>(loc, resultType, inputs)
.getResult(0);
Expand Down
17 changes: 10 additions & 7 deletions src/Dialect/Mlir/DialectBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,14 @@ Value MathBuilder::constant(Type type, double val) const {
// If unsigned, create a signless constant, then cast it to unsigned.
if (elementType.isUnsignedInteger()) {
Type signlessTy = b().getIntegerType(width);
constant = b().create<arith::ConstantOp>(loc(),
b().getIntegerAttr(signlessTy, APInt(width, (int64_t)val)));
constant = b().create<arith::ConstantOp>(
loc(), b().getIntegerAttr(signlessTy,
APInt(width, (int64_t)val, false, true)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change to c++ style cast to prevent code scan finding.

static_cast<int64_t>(val) instead of (int64_t)val

Also line 637.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeessen Thanks for keeping track of the casts. Could you look into seeing if there is away to have the compiler issue a warning (probably clang for us since that what we are using)? I am afraid that I may not be as vigilant as we should be on this issue (speaking for me on the code I modify...).

That would be greatly appreciated. Thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeessen There are actually four places that needed to be updated...so I did that for you. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeessen Thanks for keeping track of the casts. Could you look into seeing if there is away to have the compiler issue a warning (probably clang for us since that what we are using)? I am afraid that I may not be as vigilant as we should be on this issue (speaking for me on the code I modify...).

That would be greatly appreciated. Thanks

Thanks, I will take a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeessen There are actually four places that needed to be updated...so I did that for you. Thanks!

Thank you for updating!

constant = castToUnsigned(constant, width);
} else {
constant = b().create<arith::ConstantOp>(loc(),
b().getIntegerAttr(elementType, APInt(width, (int64_t)val)));
constant = b().create<arith::ConstantOp>(
loc(), b().getIntegerAttr(elementType,
APInt(width, (int64_t)val, false, true)));
}
}
})
Expand Down Expand Up @@ -695,7 +697,7 @@ TypedAttr MathBuilder::negativeInfAttr(Type type) const {
default:
llvm_unreachable("unsupported element type");
}
attr = b().getIntegerAttr(type, APInt(width, value));
attr = b().getIntegerAttr(type, APInt(width, value, false, true));
Copy link
Collaborator Author

@hamptonm1 hamptonm1 Nov 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to update the APInt with the following boolean values based on the this PR update: llvm/llvm-project#114539

Previously truncation was set to true as default and they changed it to false, we need the truncation on for our lit tests to pass and to be consistent with the previous behavior.

})
.Default([](Type) { llvm_unreachable("unsupported element type"); });
assert(attr != nullptr && "Expecting valid attribute");
Expand Down Expand Up @@ -740,7 +742,7 @@ TypedAttr MathBuilder::positiveInfAttr(Type type) const {
default:
llvm_unreachable("unsupported element type");
}
attr = b().getIntegerAttr(type, APInt(width, value));
attr = b().getIntegerAttr(type, APInt(width, value, false, true));
})
.Default([](Type) { llvm_unreachable("unsupported element type"); });
assert(attr != nullptr && "Expecting valid attribute");
Expand Down Expand Up @@ -2263,7 +2265,8 @@ Value LLVMBuilder::constant(Type type, int64_t val) const {
assert(type.isSignless() &&
"LLVM::ConstantOp requires a signless type.");
constant = b().create<LLVM::ConstantOp>(loc(), type,
b().getIntegerAttr(type, APInt(width, (int64_t)val)));
b().getIntegerAttr(
type, APInt(width, (int64_t)val, false, true)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as previous file. Please change to c++ style cast.

}
})
.Case<IndexType>([&](Type) {
Expand Down
2 changes: 1 addition & 1 deletion third_party/stablehlo
Submodule stablehlo updated 54 files
+17 −0 BUILD.bazel
+4 −0 CMakeLists.txt
+7 −2 README.md
+2 −2 WORKSPACE.bazel
+1 −1 build_tools/llvm_version.txt
+124 −0 build_tools/update_version_h_cpp.sh
+2 −0 docs/_toc.yaml
+48 −0 docs/awesome.md
+1 −0 docs/generated/stablehlo_linalg_passes.md
+7 −0 docs/generated/stablehlo_passes.md
+1 −0 docs/generated/stablehlo_tosa_passes.md
+6 −2 docs/spec.md
+435 −430 docs/tutorials/jax-export.ipynb
+118 −99 docs/tutorials/pytorch-export.ipynb
+199 −0 rfcs/20241001-microscaling-formats.md
+19 −0 stablehlo/conversions/linalg/tests/miscellaneous.mlir
+48 −5 stablehlo/conversions/linalg/tests/pointwise.mlir
+47 −45 stablehlo/conversions/linalg/transforms/StablehloToLinalgPointwise.cpp
+9 −10 stablehlo/conversions/linalg/transforms/TypeConversion.cpp
+2 −19 stablehlo/dialect/Base.cpp
+3 −2 stablehlo/dialect/Base.td
+44 −4 stablehlo/dialect/StablehloOps.cpp
+5 −2 stablehlo/dialect/Version.cpp
+1 −1 stablehlo/dialect/Version.h
+49 −1 stablehlo/dialect/VhloBytecode.cpp
+1 −0 stablehlo/dialect/VhloDialect.td
+24 −0 stablehlo/dialect/VhloTypes.cpp
+12 −0 stablehlo/dialect/VhloTypes.td
+53 −77 stablehlo/reference/Tensor.cpp
+6 −4 stablehlo/reference/Types.cpp
+1 −1 stablehlo/testdata/igamma_float64_20_20_float64_20_20_chlo.mlir
+1 −1 stablehlo/testdata/igammac_float64_20_20_float64_20_20_chlo.mlir
+16 −0 stablehlo/tests/interpret/api_input_arguments.mlir
+32 −0 stablehlo/tests/interpret/constant.mlir
+40 −8 stablehlo/tests/ops_stablehlo.mlir
+53 −53 stablehlo/tests/ops_stablehlo_quantized.mlir
+4 −0 stablehlo/tests/ops_stablehlo_roundtrip.mlir
+220 −0 stablehlo/tests/transforms/stablehlo_aggressive_folder.mlir
+1,033 −485 stablehlo/tests/transforms/stablehlo_aggressive_simplification.mlir
+2,936 −0 stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_8_0.mlir
+ stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.1_8_0.mlir.bc
+32 −0 stablehlo/tests/vhlo/stablehlo_legalize_to_vhlo.mlir
+35 −0 stablehlo/tests/vhlo/vhlo_to_version_downgrade_invalid.1_7_0.mlir
+15 −0 stablehlo/tests/vhlo/vhlo_to_version_downgrade_patch.mlir
+41 −2 stablehlo/tools/StablehloTranslateMain.cpp
+7 −2 stablehlo/transforms/CMakeLists.txt
+31 −2 stablehlo/transforms/PassUtils.cpp
+27 −12 stablehlo/transforms/PassUtils.h
+5 −0 stablehlo/transforms/Passes.h
+2 −1 stablehlo/transforms/Passes.td
+245 −7 stablehlo/transforms/StablehloAggressiveFolder.cpp
+873 −605 stablehlo/transforms/StablehloAggressiveSimplification.cpp
+417 −0 stablehlo/transforms/StablehloAggressiveSimplificationPatterns.td
+7 −0 stablehlo/transforms/VhloToVersion.cpp
2 changes: 1 addition & 1 deletion utils/clone-mlir.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
git clone -n https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX-MLIR.
cd llvm-project && git checkout 00128a20eec27246719d73ba427bf821883b00b4 && cd ..
cd llvm-project && git checkout 01d233ff403823389f8480897e41aea84ecbb3d3 && cd ..
Loading