From df2b8a4b6e7b1b24cc48ad80c42d55da5379273e Mon Sep 17 00:00:00 2001 From: Max191 <44243577+Max191@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:04:50 -0400 Subject: [PATCH] Integrate llvm-project @f1595ecfdce5387e41826fd72ff930a1a39ae398 (#18897) - bump llvm-project to https://github.com/llvm/llvm-project/commit/f1595ecfdce5387e41826fd72ff930a1a39ae398 - revert https://github.com/iree-org/llvm-project/commit/1004865f1ca41a9581da8747f34b29862d3ebc3d due to compiler failures in VectorDistribute. Tracked in https://github.com/iree-org/iree/issues/18955. - bump stablehlo to https://github.com/openxla/stablehlo/commit/c32f7c215d9bed2d4077a7f884781f02e61df292 - bump torch-mlir to https://github.com/llvm/torch-mlir/commit/8b0bf2e2930cc4ef0c9e1212b31c2c4fad2d9141 - revert https://github.com/llvm/torch-mlir/commit/55ff110dc29cab7e2495ccdbec9a60512c29c665 due to new onnx failures. Tracked in https://github.com/iree-org/iree/issues/18961 --------- Signed-off-by: Max Dawkins --- .../StableHLOToIREEInputDialects.cpp | 6 +-- .../Conversion/StableHLOToLinalgExt.cpp | 6 +-- .../StableHLO/Conversion/TypeConversion.cpp | 19 +++++----- .../Common/ConvertBf16ToUInt16Buffers.cpp | 5 +-- .../tile_and_distribute_to_workgroups.mlir | 10 +++-- .../Stream/Transforms/ConvertToStream.cpp | 37 +++++++++---------- .../Util/Transforms/TestConversion.cpp | 6 +-- .../onnx_ops/onnx_ops_cpu_llvm_sync.json | 5 +-- .../onnx_ops/onnx_ops_gpu_rocm_rdna3.json | 5 +-- .../onnx_ops/onnx_ops_gpu_vulkan.json | 9 ++--- third_party/llvm-project | 2 +- third_party/stablehlo | 2 +- third_party/torch-mlir | 2 +- 13 files changed, 53 insertions(+), 61 deletions(-) diff --git a/compiler/plugins/input/StableHLO/Conversion/StableHLOToIREEInputDialects.cpp b/compiler/plugins/input/StableHLO/Conversion/StableHLOToIREEInputDialects.cpp index 0180abbd0749..5c6b4a0099c3 100644 --- a/compiler/plugins/input/StableHLO/Conversion/StableHLOToIREEInputDialects.cpp +++ b/compiler/plugins/input/StableHLO/Conversion/StableHLOToIREEInputDialects.cpp @@ -424,11 +424,11 @@ struct GenericTypeConvert final : ConversionPattern { } }; -std::optional scalarToTensor(OpBuilder &builder, Type /*type*/, - ValueRange inputs, Location loc) { +Value scalarToTensor(OpBuilder &builder, Type /*type*/, ValueRange inputs, + Location loc) { assert(inputs.size() == 1); if (isa(inputs.front().getType())) { - return std::nullopt; + return Value(); } return builder .create( diff --git a/compiler/plugins/input/StableHLO/Conversion/StableHLOToLinalgExt.cpp b/compiler/plugins/input/StableHLO/Conversion/StableHLOToLinalgExt.cpp index cc7fa2bd2b57..831ca72158c4 100644 --- a/compiler/plugins/input/StableHLO/Conversion/StableHLOToLinalgExt.cpp +++ b/compiler/plugins/input/StableHLO/Conversion/StableHLOToLinalgExt.cpp @@ -65,13 +65,13 @@ Type convertShapedToSignless(ShapedType shapedType) { return shapedType; } -std::optional materializeCast(OpBuilder &builder, Type toType, - ValueRange inputs, Location loc) { +Value materializeCast(OpBuilder &builder, Type toType, ValueRange inputs, + Location loc) { assert(inputs.size() == 1 && "too many inputs to type conversion"); Value fromValue = inputs[0]; auto fromType = dyn_cast(fromValue.getType()); if (!fromType) - return std::nullopt; + return Value(); if (auto intFromType = dyn_cast(fromType.getElementType())) { Type castType = getElementTypeOrSelf(toType); diff --git a/compiler/plugins/input/StableHLO/Conversion/TypeConversion.cpp b/compiler/plugins/input/StableHLO/Conversion/TypeConversion.cpp index 947fcba2886b..62193b0b9698 100644 --- a/compiler/plugins/input/StableHLO/Conversion/TypeConversion.cpp +++ b/compiler/plugins/input/StableHLO/Conversion/TypeConversion.cpp @@ -31,36 +31,35 @@ Type convertShapedType(ShapedType shapedType) { return shapedType; } -std::optional materializeCastFromIllegal(OpBuilder &builder, Type type, - ValueRange inputs, - Location loc) { +Value materializeCastFromIllegal(OpBuilder &builder, Type type, + ValueRange inputs, Location loc) { Type fromType = getElementTypeOrSelf(inputs[0].getType()); Type toType = getElementTypeOrSelf(type); if ((!fromType.isSignedInteger() && !fromType.isUnsignedInteger()) || !toType.isSignlessInteger()) - return std::nullopt; + return Value(); // Use unrealized conversion casts to do signful->signless conversions. return builder.create(loc, type, inputs[0]) ->getResult(0); } -std::optional materializeCastToIllegal(OpBuilder &builder, Type type, - ValueRange inputs, Location loc) { +Value materializeCastToIllegal(OpBuilder &builder, Type type, ValueRange inputs, + Location loc) { Type fromType = getElementTypeOrSelf(inputs[0].getType()); Type toType = getElementTypeOrSelf(type); if (!fromType.isSignlessInteger() || (!toType.isSignedInteger() && !toType.isUnsignedInteger())) - return std::nullopt; + return Value(); // Use unrealized conversion casts to do signless->signful conversions. return builder.create(loc, type, inputs[0]) ->getResult(0); } -std::optional scalarToTensor(OpBuilder &builder, Type type, - ValueRange inputs, Location loc) { +Value scalarToTensor(OpBuilder &builder, Type type, ValueRange inputs, + Location loc) { assert(inputs.size() == 1); if (llvm::isa(inputs.front().getType())) { - return std::nullopt; + return Value(); } auto tensor = builder diff --git a/compiler/src/iree/compiler/Codegen/Common/ConvertBf16ToUInt16Buffers.cpp b/compiler/src/iree/compiler/Codegen/Common/ConvertBf16ToUInt16Buffers.cpp index bc9420f26559..0efe1fd19f93 100644 --- a/compiler/src/iree/compiler/Codegen/Common/ConvertBf16ToUInt16Buffers.cpp +++ b/compiler/src/iree/compiler/Codegen/Common/ConvertBf16ToUInt16Buffers.cpp @@ -229,9 +229,8 @@ struct ConvertMemRefStore final : OpConversionPattern { // Helper functions //===----------------------------------------------------------------------===// -std::optional materializeArithBitcast(OpBuilder &builder, Type resultTy, - mlir::ValueRange inputs, - mlir::Location loc) { +Value materializeArithBitcast(OpBuilder &builder, Type resultTy, + mlir::ValueRange inputs, mlir::Location loc) { return builder.create(loc, resultTy, inputs); } diff --git a/compiler/src/iree/compiler/Codegen/Common/test/tile_and_distribute_to_workgroups.mlir b/compiler/src/iree/compiler/Codegen/Common/test/tile_and_distribute_to_workgroups.mlir index 408885d729dd..71e8351958d8 100644 --- a/compiler/src/iree/compiler/Codegen/Common/test/tile_and_distribute_to_workgroups.mlir +++ b/compiler/src/iree/compiler/Codegen/Common/test/tile_and_distribute_to_workgroups.mlir @@ -2088,9 +2088,7 @@ hal.executable private @dynamic_unpack { // ----- -#pipeline_layout = #hal.pipeline.layout, - #hal.pipeline.binding, +#pipeline_layout = #hal.pipeline.layout, #hal.pipeline.binding ]> @@ -2111,10 +2109,14 @@ hal.executable private @dynamic_unpack_dynamic_tile { %cl_1 = hal.interface.constant.load layout(#pipeline_layout) ordinal(1) : i32 %cl_2 = hal.interface.constant.load layout(#pipeline_layout) ordinal(2) : i32 %cl_3 = hal.interface.constant.load layout(#pipeline_layout) ordinal(3) : i32 + %cl_4 = hal.interface.constant.load layout(#pipeline_layout) ordinal(4) : i32 + %cl_5 = hal.interface.constant.load layout(#pipeline_layout) ordinal(5) : i32 %0 = arith.index_castui %cl_0 : i32 to index %1 = arith.index_castui %cl_1 : i32 to index %2 = arith.index_castui %cl_2 : i32 to index %3 = arith.index_castui %cl_3 : i32 to index + %tile0 = arith.index_castui %cl_3 : i32 to index + %tile1 = arith.index_castui %cl_3 : i32 to index %4 = flow.dispatch.workload.ordinal %0, 0 : index %5 = flow.dispatch.workload.ordinal %1, 1 : index %6 = flow.dispatch.workload.ordinal %2, 2 : index @@ -2123,7 +2125,7 @@ hal.executable private @dynamic_unpack_dynamic_tile { %9 = hal.interface.binding.subspan layout(#pipeline_layout) binding(1) alignment(64) offset(%c131072) : !flow.dispatch.tensor>{%6, %7} %10 = flow.dispatch.tensor.load %8, offsets = [0, 0, 0, 0], sizes = [%4, %5, %c32, %c16], strides = [1, 1, 1, 1] : !flow.dispatch.tensor>{%4, %5, %c32, %c16} -> tensor %11 = tensor.empty(%6, %7) : tensor - %12 = tensor.unpack %10 inner_dims_pos = [0, 1] inner_tiles = [%c32, %c16] into %11 + %12 = tensor.unpack %10 inner_dims_pos = [0, 1] inner_tiles = [%tile0, %tile1] into %11 {lowering_config = #iree_codegen.lowering_config} : tensor -> tensor flow.dispatch.tensor.store %12, %9, offsets = [0, 0], sizes = [%6, %7], strides = [1, 1] : tensor -> !flow.dispatch.tensor>{%6, %7} diff --git a/compiler/src/iree/compiler/Dialect/Stream/Transforms/ConvertToStream.cpp b/compiler/src/iree/compiler/Dialect/Stream/Transforms/ConvertToStream.cpp index 92a3457dfa22..0da7d95f486d 100644 --- a/compiler/src/iree/compiler/Dialect/Stream/Transforms/ConvertToStream.cpp +++ b/compiler/src/iree/compiler/Dialect/Stream/Transforms/ConvertToStream.cpp @@ -261,25 +261,24 @@ struct ConvertToStreamPass final resultTypes.push_back(indexType); return success(); }); - typeConverter.addArgumentMaterialization( - [](OpBuilder &builder, TensorType resultType, ValueRange inputs, - Location loc) -> std::optional { - assert(inputs.size() >= 2); - auto resourceValue = inputs[0]; - auto resourceSize = inputs[1]; - assert(inputs.size() == 2 && - "expecting 2 operands (resource + size)"); - Value cast = builder - .create( - loc, resourceValue.getType(), resourceValue, - resourceSize, resourceSize, - /*source_affinity=*/nullptr, - /*result_affinity=*/nullptr) - .getResult(); - return builder - .create(loc, resultType, cast) - .getResult(0); - }); + typeConverter.addArgumentMaterialization([](OpBuilder &builder, + TensorType resultType, + ValueRange inputs, + Location loc) -> Value { + assert(inputs.size() >= 2); + auto resourceValue = inputs[0]; + auto resourceSize = inputs[1]; + assert(inputs.size() == 2 && "expecting 2 operands (resource + size)"); + Value cast = builder + .create( + loc, resourceValue.getType(), resourceValue, + resourceSize, resourceSize, + /*source_affinity=*/nullptr, + /*result_affinity=*/nullptr) + .getResult(); + return builder.create(loc, resultType, cast) + .getResult(0); + }); populateUtilConversionPatterns(context, conversionTarget, typeConverter, patterns); diff --git a/compiler/src/iree/compiler/Dialect/Util/Transforms/TestConversion.cpp b/compiler/src/iree/compiler/Dialect/Util/Transforms/TestConversion.cpp index 0675ceafdb13..c57cca1855ab 100644 --- a/compiler/src/iree/compiler/Dialect/Util/Transforms/TestConversion.cpp +++ b/compiler/src/iree/compiler/Dialect/Util/Transforms/TestConversion.cpp @@ -20,10 +20,8 @@ namespace mlir::iree_compiler::IREE::Util { namespace { -static std::optional buildUnrealizedConversionCastOp(OpBuilder &builder, - Type toType, - ValueRange inputs, - Location loc) { +static Value buildUnrealizedConversionCastOp(OpBuilder &builder, Type toType, + ValueRange inputs, Location loc) { return builder.create(loc, toType, inputs) .getResult(0); } diff --git a/tests/external/iree-test-suites/onnx_ops/onnx_ops_cpu_llvm_sync.json b/tests/external/iree-test-suites/onnx_ops/onnx_ops_cpu_llvm_sync.json index f8ca790fe5b1..7242c4038ca5 100644 --- a/tests/external/iree-test-suites/onnx_ops/onnx_ops_cpu_llvm_sync.json +++ b/tests/external/iree-test-suites/onnx_ops/onnx_ops_cpu_llvm_sync.json @@ -149,7 +149,6 @@ "onnx/node/generated/test_lppool_2d_same_lower", "onnx/node/generated/test_lppool_2d_same_upper", "onnx/node/generated/test_maxpool_2d_ceil_output_size_reduce_by_one", - "onnx/node/generated/test_maxpool_2d_precomputed_same_upper", "onnx/node/generated/test_maxpool_2d_same_lower", "onnx/node/generated/test_maxpool_2d_same_upper", "onnx/node/generated/test_maxpool_with_argmax_2d_precomputed_strides", @@ -380,6 +379,7 @@ "onnx/node/generated/test_sce_none_weights_expanded", "onnx/node/generated/test_sce_none_weights_log_prob", "onnx/node/generated/test_sce_none_weights_log_prob_expanded", + "onnx/node/generated/test_shape_clip_start", "onnx/node/generated/test_shape_end_negative_1", "onnx/node/generated/test_slice", "onnx/node/generated/test_slice_default_steps", @@ -438,9 +438,8 @@ "onnx/node/generated/test_reduce_min_empty_set", "onnx/node/generated/test_reduce_sum_empty_set_non_reduced_axis_zero", "onnx/node/generated/test_resize_downsample_scales_linear_align_corners", - "onnx/node/generated/test_scan_sum", "onnx/node/generated/test_scan9_sum", - "onnx/node/generated/test_shape_clip_start", + "onnx/node/generated/test_scan_sum", "onnx/node/generated/test_shape_end_1", "onnx/node/generated/test_shape_start_1", "onnx/node/generated/test_shape_start_1_end_2", diff --git a/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_rocm_rdna3.json b/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_rocm_rdna3.json index 79cc5a9a4add..a8713b67d51e 100644 --- a/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_rocm_rdna3.json +++ b/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_rocm_rdna3.json @@ -153,7 +153,6 @@ "onnx/node/generated/test_lppool_2d_same_lower", "onnx/node/generated/test_lppool_2d_same_upper", "onnx/node/generated/test_maxpool_2d_ceil_output_size_reduce_by_one", - "onnx/node/generated/test_maxpool_2d_precomputed_same_upper", "onnx/node/generated/test_maxpool_2d_same_lower", "onnx/node/generated/test_maxpool_2d_same_upper", "onnx/node/generated/test_maxpool_with_argmax_2d_precomputed_strides", @@ -381,6 +380,7 @@ "onnx/node/generated/test_sce_none_weights_expanded", "onnx/node/generated/test_sce_none_weights_log_prob", "onnx/node/generated/test_sce_none_weights_log_prob_expanded", + "onnx/node/generated/test_shape_clip_start", "onnx/node/generated/test_shape_end_negative_1", "onnx/node/generated/test_slice", "onnx/node/generated/test_slice_default_steps", @@ -488,11 +488,10 @@ "onnx/node/generated/test_reduce_sum_square_default_axes_keepdims_random", "onnx/node/generated/test_reduce_sum_square_default_axes_keepdims_random_expanded", "onnx/node/generated/test_resize_downsample_scales_linear_align_corners", - "onnx/node/generated/test_scan_sum", "onnx/node/generated/test_scan9_sum", + "onnx/node/generated/test_scan_sum", "onnx/node/generated/test_shape", "onnx/node/generated/test_shape_clip_end", - "onnx/node/generated/test_shape_clip_start", "onnx/node/generated/test_shape_end_1", "onnx/node/generated/test_shape_example", "onnx/node/generated/test_shape_start_1", diff --git a/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_vulkan.json b/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_vulkan.json index 8c31c26a421a..eb2dee2ff978 100644 --- a/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_vulkan.json +++ b/tests/external/iree-test-suites/onnx_ops/onnx_ops_gpu_vulkan.json @@ -195,9 +195,6 @@ "onnx/node/generated/test_max_uint16", "onnx/node/generated/test_max_uint8", "onnx/node/generated/test_maxpool_2d_ceil_output_size_reduce_by_one", - "onnx/node/generated/test_maxpool_2d_precomputed_same_upper", - "onnx/node/generated/test_maxpool_2d_same_lower", - "onnx/node/generated/test_maxpool_2d_same_upper", "onnx/node/generated/test_maxpool_with_argmax_2d_precomputed_strides", "onnx/node/generated/test_maxunpool_export_with_output_shape", "onnx/node/generated/test_maxunpool_export_without_output_shape", @@ -447,6 +444,7 @@ "onnx/node/generated/test_sce_none_weights_expanded", "onnx/node/generated/test_sce_none_weights_log_prob", "onnx/node/generated/test_sce_none_weights_log_prob_expanded", + "onnx/node/generated/test_shape_clip_start", "onnx/node/generated/test_shape_end_negative_1", "onnx/node/generated/test_slice", "onnx/node/generated/test_slice_default_steps", @@ -533,8 +531,8 @@ "onnx/node/generated/test_dynamicquantizelinear_expanded", "onnx/node/generated/test_einsum_batch_diagonal", "onnx/node/generated/test_einsum_batch_matmul", - "onnx/node/generated/test_einsum_transpose", "onnx/node/generated/test_einsum_sum", + "onnx/node/generated/test_einsum_transpose", "onnx/node/generated/test_eyelike_with_dtype", "onnx/node/generated/test_isinf_float16", "onnx/node/generated/test_isnan_float16", @@ -595,9 +593,8 @@ "onnx/node/generated/test_reduce_sum_square_default_axes_keepdims_example_expanded", "onnx/node/generated/test_reduce_sum_square_default_axes_keepdims_random", "onnx/node/generated/test_reduce_sum_square_default_axes_keepdims_random_expanded", - "onnx/node/generated/test_scan_sum", "onnx/node/generated/test_scan9_sum", - "onnx/node/generated/test_shape_clip_start", + "onnx/node/generated/test_scan_sum", "onnx/node/generated/test_shape_end_1", "onnx/node/generated/test_shape_start_1", "onnx/node/generated/test_shape_start_1_end_2", diff --git a/third_party/llvm-project b/third_party/llvm-project index 864902e9b4d8..9eee6446f367 160000 --- a/third_party/llvm-project +++ b/third_party/llvm-project @@ -1 +1 @@ -Subproject commit 864902e9b4d8bc6d3f0852d5c475e3dc97dd8335 +Subproject commit 9eee6446f367cb35113b3d32545d16eecd1d8f14 diff --git a/third_party/stablehlo b/third_party/stablehlo index c49487b26835..c32f7c215d9b 160000 --- a/third_party/stablehlo +++ b/third_party/stablehlo @@ -1 +1 @@ -Subproject commit c49487b26835b15ac21508c857df8ecf0ccf23e3 +Subproject commit c32f7c215d9bed2d4077a7f884781f02e61df292 diff --git a/third_party/torch-mlir b/third_party/torch-mlir index 140cad5659bb..1570c151e949 160000 --- a/third_party/torch-mlir +++ b/third_party/torch-mlir @@ -1 +1 @@ -Subproject commit 140cad5659bb779bb1f5de1888566db5b5d21236 +Subproject commit 1570c151e9491e2ca77687a4fd457ae00491b02e