Skip to content

Commit

Permalink
bump LLVM to 765206 and stablehlo to 3c6a06
Browse files Browse the repository at this point in the history
Signed-off-by: Yan Xu <[email protected]>
  • Loading branch information
Connor-XY committed Jun 5, 2024
1 parent f2bccef commit bc32b83
Show file tree
Hide file tree
Showing 20 changed files with 691 additions and 674 deletions.
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 20ed5b1f45871612570d3bd447121ac43e083c6a && cd ..
cd llvm-project && git checkout 765206e050453018e861637a08a4520f29238074 && 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 20ed5b1f45871612570d3bd447121ac43e083c6a && cd ..
cd llvm-project && git checkout 765206e050453018e861637a08a4520f29238074 && cd ..
```

[same-as-file]: <> (utils/build-mlir.cmd)
Expand Down
2 changes: 2 additions & 0 deletions src/Conversion/ONNXToStablehlo/Tensor/GatherElements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ struct ONNXGatherElementsOpLoweringToStablehlo : public ConversionPattern {
stablehlo::GatherDimensionNumbersAttr::get(rewriter.getContext(),
/*offsetDims=*/{},
/*collapsedSliceDims=*/collapsedDims,
/*operandBatchingDims=*/{},
/*startIndicesBatchingDims=*/{},
/*startIndexMap=*/startIndexMap,
/*indexVecDim=*/rank);
SmallVector<int64_t> sliceSizes(inputType.getRank(), 1);
Expand Down
2 changes: 2 additions & 0 deletions src/Conversion/ONNXToStablehlo/Tensor/ScatterND.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ struct ONNXScatterNDOpLoweringToStablehlo
llvm::to_vector<4>(llvm::seq<int64_t>(partialIdxDim, dataRank)),
/*insertedWindowDims*/
llvm::to_vector<4>(llvm::seq<int64_t>(0, partialIdxDim)),
/*inputBatchingDims=*/{},
/*scatterIndicesBatchingDims=*/{},
/*scatterDimsToOperandDims*/
llvm::to_vector<4>(llvm::seq<int64_t>(0, partialIdxDim)),
/*indexVectorDim=*/indicesRank - 1);
Expand Down
4 changes: 2 additions & 2 deletions src/Conversion/ONNXToTOSA/DialectBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Value TosaBuilder::intdiv(mlir::Value &lhs, mlir::Value &rhs) {
Type rhsElementType = rhs.getType().cast<ShapedType>().getElementType();
assert((lhsElementType.isSignlessInteger(32) &&
rhsElementType.isSignlessInteger(32)) &&
"Tosa DivOp needs 32-bit signless integer inputs");
"Tosa IntDivOp needs 32-bit signless integer inputs");

if (needsRankBroadcast({lhs, rhs})) {
llvm::SmallVector<Value, 4> valueVec = equalizeRanks({lhs, rhs});
Expand All @@ -199,7 +199,7 @@ Value TosaBuilder::intdiv(mlir::Value &lhs, mlir::Value &rhs) {
Type newValueType = RankedTensorType::get(
llvm::SmallVector<int64_t, 4>(lhsType.getRank(), ShapedType::kDynamic),
lhsElementType);
return tosa::CreateOpAndInfer<mlir::tosa::DivOp>(
return tosa::CreateOpAndInfer<mlir::tosa::IntDivOp>(
rewriter(), loc(), newValueType, lhs, rhs);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Conversion/ONNXToTOSA/Math/Elementwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class ONNXDivOpLoweringToTOSA : public OpConversionPattern<ONNXDivOp> {
TosaBuilder tosaBuilder(rewriter, op->getLoc());

if (resultElementType.isSignlessInteger(32)) {
// tosa::DivOp takes 32-but signless integers as inputs
// tosa::IntDivOp takes 32-but signless integers as inputs
Value divOp = tosaBuilder.intdiv(lhs, rhs);
rewriter.replaceOp(op, {divOp});
return success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func.func @krnl_get_linear_offset_index_1(%arg0: memref<?x128x256xf32, #map>, %a
%c10 = arith.constant 10: index
%0 = memref.alloc(%arg1) : memref<?x128x256xf32, #map>
%1 = krnl.get_linear_offset_index %arg0 at [%arg2, %c5, %c10] : memref<?x128x256xf32, #map>
return %1: index
return %1: index

// CHECK-LABEL: func.func @krnl_get_linear_offset_index
// CHECK: [[VAR_0_:%.+]] = krnl.get_linear_offset_index {{.*}} at {{.*}} : memref<?x128x256xf32, #map>
Expand Down Expand Up @@ -127,7 +127,7 @@ func.func @prefetch(%arg0: memref<256x512xf32>) -> memref<256x512xf32> attribute
// CHECK: affine.for [[I_0_:%.+]] = 0 to 256 {
// CHECK: affine.for [[I_1_:%.+]] = 0 to 512 {
// CHECK: [[LOAD_PARAM_0_MEM_:%.+]] = affine.load [[PARAM_0_]]{{.}}[[I_0_]], [[I_1_]]{{.}} : memref<256x512xf32>
// CHECK: affine.prefetch [[PARAM_0_]]{{.}}[[I_0_]], [[I_1_]] + 64], write, locality<0>, data : memref<256x512xf32>
// CHECK: affine.prefetch [[PARAM_0_]]{{.}}[[I_0_]], [[I_1_]] + 64], read, locality<3>, data : memref<256x512xf32>
// CHECK: [[LOAD_PARAM_0_MEM_1_:%.+]] = affine.load [[PARAM_0_]]{{.}}[[I_0_]], [[I_1_]]{{.}} : memref<256x512xf32>
// CHECK: [[VAR_2_:%.+]] = arith.addf [[LOAD_PARAM_0_MEM_]], [[LOAD_PARAM_0_MEM_1_]] : f32
// CHECK: affine.store [[VAR_2_]], [[RES_]]{{.}}[[I_0_]], [[I_1_]]{{.}} : memref<256x512xf32>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// RUN: onnx-mlir-opt --convert-krnl-to-llvm="store-constants-to-file constants-to-file-single-threshold=0.03 constants-to-file-total-threshold=0.00000006" --canonicalize %s -split-input-file | FileCheck %s && rm model.constants.bin

// Thresholds for this files:
// -constants-to-file-single-threshold=0.03: 30 bytes for a single constants
// -constants-to-file-total-threshold=0.00000006: 60 bytes for all constants
// Thresholds for this files:
// -constants-to-file-single-threshold=0.03: 30 bytes for a single constants
// -constants-to-file-total-threshold=0.00000006: 60 bytes for all constants

// Donot save to file if a constant is a return value.
module {
Expand All @@ -11,7 +11,7 @@ func.func @test_constants_to_file_return_value() -> memref<10xi64> {
return %0 : memref<10xi64>

// CHECK-LABEL: module
// CHECK: llvm.mlir.global internal constant @constant(dense<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]> : tensor<10xi64>) {addr_space = 0 : i32, alignment = 4096 : i64} : !llvm.array<10 x i64>
// CHECK: llvm.mlir.global internal constant @constant(dense<[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]> : tensor<10xi64>) {addr_space = 0 : i32, alignment = 4096 : i64} : !llvm.array<10 x i64>
}
}

Expand Down Expand Up @@ -60,17 +60,16 @@ func.func @test_constants_to_file() -> memref<10xi64> {

// CHECK: llvm.func @omLoadConstantsFromFile() {
// CHECK-DAG: [[VAR_0_9_:%.+]] = llvm.mlir.constant(4096 : i64) : i64
// CHECK-DAG: [[VAR_1_3_:%.+]] = llvm.mlir.constant(4176 : i64) : i64
// CHECK-DAG: [[VAR_1_3_:%.+]] = llvm.mlir.addressof @om_external_constant_data_constant_0 : !llvm.ptr
// CHECK-DAG: [[VAR_2_3_:%.+]] = llvm.mlir.constant(0 : i64) : i64
// CHECK-DAG: [[VAR_2_4_:%.+]] = llvm.mlir.constant(1 : i64) : i64
// CHECK-DAG: [[VAR_3_3_:%.+]] = llvm.mlir.addressof @om_external_constant_filename : !llvm.ptr
// CHECK-NOT: separator of consecutive DAGs
// CHECK-DAG: [[VAR_5_3_:%.+]] = llvm.mlir.addressof @om_external_constant_packedConst : !llvm.ptr
// CHECK: llvm.call @omMMapBinaryFile([[VAR_5_3_]], [[VAR_3_3_]], [[VAR_1_3_]], [[VAR_2_4_]]) : (!llvm.ptr, !llvm.ptr, i64, i64) -> ()
// CHECK: [[VAR_7_3_:%.+]] = llvm.mlir.addressof @om_external_constant_data_constant_1 : !llvm.ptr
// CHECK: llvm.call @omGetExternalConstantAddr([[VAR_7_3_]], [[VAR_5_3_]], [[VAR_2_3_]]) : (!llvm.ptr, !llvm.ptr, i64) -> ()
// CHECK: [[VAR_9_3_:%.+]] = llvm.mlir.addressof @om_external_constant_data_constant_0 : !llvm.ptr
// CHECK: llvm.call @omGetExternalConstantAddr([[VAR_9_3_]], [[VAR_5_3_]], [[VAR_0_9_]]) : (!llvm.ptr, !llvm.ptr, i64) -> ()
// CHECK-DAG: [[VAR_3_3_:%.+]] = llvm.mlir.addressof @om_external_constant_data_constant_1 : !llvm.ptr
// CHECK-DAG: [[VAR_4_3_:%.+]] = llvm.mlir.constant(4176 : i64) : i64
// CHECK-DAG: [[VAR_5_3_:%.+]] = llvm.mlir.constant(1 : i64) : i64
// CHECK-DAG: [[VAR_6_3_:%.+]] = llvm.mlir.addressof @om_external_constant_packedConst : !llvm.ptr
// CHECK-DAG: [[VAR_7_3_:%.+]] = llvm.mlir.addressof @om_external_constant_filename : !llvm.ptr
// CHECK: llvm.call @omMMapBinaryFile([[VAR_6_3_]], [[VAR_7_3_]], [[VAR_4_3_]], [[VAR_5_3_]]) : (!llvm.ptr, !llvm.ptr, i64, i64) -> ()
// CHECK: llvm.call @omGetExternalConstantAddr([[VAR_3_3_]], [[VAR_6_3_]], [[VAR_2_3_]]) : (!llvm.ptr, !llvm.ptr, i64) -> ()
// CHECK: llvm.call @omGetExternalConstantAddr([[VAR_1_3_]], [[VAR_6_3_]], [[VAR_0_9_]]) : (!llvm.ptr, !llvm.ptr, i64) -> ()
// CHECK: llvm.return
// CHECK: }

Expand Down
Loading

0 comments on commit bc32b83

Please sign in to comment.