Skip to content

Commit b800036

Browse files
hamptonm1MegoHam21
andauthored
Co-authored-by: Megan Hampton <[email protected]>
1 parent 9f9de36 commit b800036

File tree

16 files changed

+43
-87
lines changed

16 files changed

+43
-87
lines changed

docs/BuildOnLinuxOSX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
1515
``` bash
1616
git clone -n https://github.com/llvm/llvm-project.git
1717
# Check out a specific branch that is known to work with ONNX-MLIR.
18-
cd llvm-project && git checkout 00128a20eec27246719d73ba427bf821883b00b4 && cd ..
18+
cd llvm-project && git checkout 01d233ff403823389f8480897e41aea84ecbb3d3 && cd ..
1919
```
2020

2121
[same-as-file]: <> (utils/build-mlir.sh)

docs/BuildOnWindows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Install MLIR (as a part of LLVM-Project):
5252
```shell
5353
git clone -n https://github.com/llvm/llvm-project.git
5454
# Check out a specific branch that is known to work with ONNX-MLIR.
55-
cd llvm-project && git checkout 00128a20eec27246719d73ba427bf821883b00b4 && cd ..
55+
cd llvm-project && git checkout 01d233ff403823389f8480897e41aea84ecbb3d3 && cd ..
5656
```
5757

5858
[same-as-file]: <> (utils/build-mlir.cmd)

docs/Dialects/krnl.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ _Indicate ONNX entry point_
329329

330330
The "krnl.entry_point" function indicates the main entry
331331
point of ONNX model.
332+
332333
### `krnl.erf` (KrnlErfOp)
333334

334335
_Krnl erf scalar operation_
@@ -453,7 +454,7 @@ in the `value` dense element attribute.
453454

454455
Traits: `AlwaysSpeculatableImplTrait`, `MemRefsNormalizable`
455456

456-
Interfaces: `ConditionallySpeculatable`, `KrnlGlobalOpInterface`, `NoMemoryEffect (MemoryEffectOpInterface)`
457+
Interfaces: `ConditionallySpeculatable`, `NoMemoryEffect (MemoryEffectOpInterface)`
457458

458459
Effects: `MemoryEffects::Effect{}`
459460

docs/Dialects/zhigh.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,6 @@ Effects: `MemoryEffects::Effect{}`
793793
_ZHigh Stickified Constant operation_
794794

795795
This operator produces a constant tensor to store stickified data.
796-
`value` attribute has original constant or stickified constant.
797-
`stickified` attribute indicates the `value` is already stickified or not.
798796
Stickified data is opaque and must be 4K-aligned. One who produces
799797
the stickified data must make sure its size in bytes consistent with
800798
the output tensor's size.
@@ -809,7 +807,6 @@ Effects: `MemoryEffects::Effect{}`
809807

810808
<table>
811809
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
812-
<tr><td><code>stickified</code></td><td>::mlir::BoolAttr</td><td>bool attribute</td></tr>
813810
<tr><td><code>value</code></td><td>::mlir::Attribute</td><td>any attribute</td></tr>
814811
<tr><td><code>alignment</code></td><td>::mlir::IntegerAttr</td><td>64-bit signless integer attribute</td></tr>
815812
</table>

docs/Dialects/zlow.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -752,34 +752,6 @@ Interfaces: `MemoryEffectOpInterface`
752752
| `X` | memref of 16-bit float or 32-bit float values
753753
| `Out` | memref of dlfloat16 type values
754754

755-
### `zlow.stickifiedConstant` (::onnx_mlir::zlow::ZLowStickifiedConstantOp)
756-
757-
_ZLow Stickified Constant operation._
758-
759-
760-
Traits: `MemRefsNormalizable`
761-
762-
Interfaces: `KrnlGlobalOpInterface`
763-
764-
#### Attributes:
765-
766-
<table>
767-
<tr><th>Attribute</th><th>MLIR Type</th><th>Description</th></tr>
768-
<tr><td><code>shape</code></td><td>::mlir::Attribute</td><td>any attribute</td></tr>
769-
<tr><td><code>name</code></td><td>::mlir::StringAttr</td><td>string attribute</td></tr>
770-
<tr><td><code>stickified</code></td><td>::mlir::BoolAttr</td><td>bool attribute</td></tr>
771-
<tr><td><code>value</code></td><td>::mlir::Attribute</td><td>any attribute</td></tr>
772-
<tr><td><code>layout</code></td><td>::mlir::StringAttr</td><td>string attribute</td></tr>
773-
<tr><td><code>offset</code></td><td>::mlir::IntegerAttr</td><td>64-bit signless integer attribute</td></tr>
774-
<tr><td><code>alignment</code></td><td>::mlir::IntegerAttr</td><td>64-bit signless integer attribute</td></tr>
775-
</table>
776-
777-
#### Results:
778-
779-
| Result | Description |
780-
| :----: | ----------- |
781-
| `output` | memref of dlfloat16 type values
782-
783755
### `zlow.sub` (::onnx_mlir::zlow::ZLowSubOp)
784756

785757
_ZLow sub operation_

src/Accelerators/NNPA/Transform/ZLow/ZLowStickExpansion.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ class UnstickExpansionPattern : public OpRewritePattern<ZLowUnstickOp> {
153153
// 64.
154154
IndexExpr T = LitIE(2);
155155
DimsExpr reallocTileDims = {T, lit64};
156-
Value inputAsTx64 =
157-
create.mem.reinterpretCast(input, litZero.getValue(), reallocTileDims);
158-
156+
Value inputAsTx64 = create.mem.reinterpretCast(input, reallocTileDims);
159157
// Outer loop (E4, E3, E2, E1 iterates over tiles of 64 elements)
160158
create.krnl.iterateIE(loopDefs, loopDefs, lbs, ubs,
161159
[&](const KrnlBuilder &b, ValueRange loopInd) {
@@ -456,8 +454,7 @@ class StickExpansionPattern : public OpRewritePattern<ZLowStickOp> {
456454
// 64 elements.
457455
IndexExpr T = LitIE(2);
458456
DimsExpr reallocTileDims = {T, lit64};
459-
Value allocAsTx64 =
460-
create.mem.reinterpretCast(alloc, litZero.getValue(), reallocTileDims);
457+
Value allocAsTx64 = create.mem.reinterpretCast(alloc, reallocTileDims);
461458

462459
// Outer loop (E1 iterates over tiles of 64 elements).
463460
create.krnl.iterateIE(loopDefs, loopDefs, lbs, ubs,

src/Conversion/KrnlToAffine/ConvertKrnlToAffine.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,20 +814,18 @@ AffineTypeConverter::AffineTypeConverter() {
814814
addConversion([](Type type) { return type; });
815815

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

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

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

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

src/Conversion/ONNXToKrnl/ONNXToKrnlCommon.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -547,20 +547,18 @@ KrnlTypeConverter::KrnlTypeConverter() {
547547
});
548548

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

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

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

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

src/Dialect/Mlir/DialectBuilder.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ Value MathBuilder::constant(Type type, double val) const {
617617
b().create<arith::ConstantOp>(loc(), b().getF64FloatAttr(val));
618618
})
619619
.Case<IntegerType>([&](IntegerType elementType) {
620-
assert(val == (int64_t)val && "value is ambiguous");
620+
assert(val == static_cast<int64_t>(val) && "value is ambiguous");
621621
unsigned width = elementType.getWidth();
622622

623623
if (width == 1)
@@ -628,11 +628,13 @@ Value MathBuilder::constant(Type type, double val) const {
628628
if (elementType.isUnsignedInteger()) {
629629
Type signlessTy = b().getIntegerType(width);
630630
constant = b().create<arith::ConstantOp>(loc(),
631-
b().getIntegerAttr(signlessTy, APInt(width, (int64_t)val)));
631+
b().getIntegerAttr(signlessTy,
632+
APInt(width, static_cast<int64_t>(val), false, true)));
632633
constant = castToUnsigned(constant, width);
633634
} else {
634635
constant = b().create<arith::ConstantOp>(loc(),
635-
b().getIntegerAttr(elementType, APInt(width, (int64_t)val)));
636+
b().getIntegerAttr(elementType,
637+
APInt(width, static_cast<int64_t>(val), false, true)));
636638
}
637639
}
638640
})
@@ -695,7 +697,7 @@ TypedAttr MathBuilder::negativeInfAttr(Type type) const {
695697
default:
696698
llvm_unreachable("unsupported element type");
697699
}
698-
attr = b().getIntegerAttr(type, APInt(width, value));
700+
attr = b().getIntegerAttr(type, APInt(width, value, false, true));
699701
})
700702
.Default([](Type) { llvm_unreachable("unsupported element type"); });
701703
assert(attr != nullptr && "Expecting valid attribute");
@@ -740,7 +742,7 @@ TypedAttr MathBuilder::positiveInfAttr(Type type) const {
740742
default:
741743
llvm_unreachable("unsupported element type");
742744
}
743-
attr = b().getIntegerAttr(type, APInt(width, value));
745+
attr = b().getIntegerAttr(type, APInt(width, value, false, true));
744746
})
745747
.Default([](Type) { llvm_unreachable("unsupported element type"); });
746748
assert(attr != nullptr && "Expecting valid attribute");
@@ -2263,7 +2265,8 @@ Value LLVMBuilder::constant(Type type, int64_t val) const {
22632265
assert(type.isSignless() &&
22642266
"LLVM::ConstantOp requires a signless type.");
22652267
constant = b().create<LLVM::ConstantOp>(loc(), type,
2266-
b().getIntegerAttr(type, APInt(width, (int64_t)val)));
2268+
b().getIntegerAttr(
2269+
type, APInt(width, static_cast<int64_t>(val), false, true)));
22672270
}
22682271
})
22692272
.Case<IndexType>([&](Type) {

test/mlir/accelerators/nnpa/driver/matmul-div-in-attention-layer.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ func.func @matmul_div(%arg0: tensor<?x12x?x64xf32>) -> tensor<?x?x?x?xf32> {
88
%r = "onnx.Div"(%m, %scalar) : (tensor<?x12x?x?xf32>, tensor<f32>) -> tensor<?x12x?x?xf32>
99
"onnx.Return"(%r) : (tensor<?x12x?x?xf32>) -> ()
1010

11-
// CHECK-LABEL: func.func @matmul_div
11+
// CHECK-LABEL: func.func @matmul_div
1212
// CHECK: memref.alloc
1313
// CHECK: memref.alloc
1414
// CHECK: [[ALLOC:%.+]] = memref.alloc({{.*}}) {{.*}}: memref<?x?x1x?x32x64xf16>
1515
// CHECK-DAG: [[MATMUL_RES:%.+]] = memref.cast [[ALLOC]] : memref<?x?x1x?x32x64xf16> to memref<?x?x1x?x?x?xf16>
1616
// CHECK: "zlow.matmul"({{.*}}, {{.*}}, {{.*}}, {{.*}}, [[MATMUL_RES]]) {is_bcast = 0 : si64, is_stacked = -1 : si64} : (memref<?x1x1x?x?x64xf16>, memref<?x?x1x2x32x?xf16>, memref<?x?x1x1x32x?xf16>, memref<4xi64>, memref<?x?x1x?x?x?xf16>) -> ()
17-
// CHECK-NOT: "zlow.stick"
18-
// CHECK-NOT: "zlow.unstick"
17+
// CHECK-NOT: "zlow.stick"
18+
// CHECK-NOT: "zlow.unstick"
1919
// CHECK: "zlow.div"([[MATMUL_RES]], {{.*}}, {{.*}}, {{.*}}) {layout = "3DS"} : (memref<?x?x1x?x?x?xf16>, memref<?x?x1x?x?x?xf16>, memref<3xi64>, memref<?x?x1x?x?x?xf16>) -> ()
2020
}

0 commit comments

Comments
 (0)