Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Max191 authored Oct 25, 2024
1 parent 5ae7716 commit 6e403b1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ workspace(name = "stablehlo")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

LLVM_COMMIT = "12bcea3292a1559ecad549b5d34c8abcf19f2626"
LLVM_COMMIT = "6c64c8a6f3f77c30745c751d4163ff6bf2fc323b"

LLVM_SHA256 = "1ce4ec480f47e8b46cea858a652d18dff18844c821d18836c41edbf36151c209"
LLVM_SHA256 = "a27f8452e8a4267acb7bf59ea4dae012cec22e37624a67206b927985554e3640"

http_archive(
name = "llvm-raw",
Expand Down
2 changes: 1 addition & 1 deletion build_tools/llvm_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12bcea3292a1559ecad549b5d34c8abcf19f2626
6c64c8a6f3f77c30745c751d4163ff6bf2fc323b
1 change: 1 addition & 0 deletions docs/generated/stablehlo_linalg_passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
_Legalize StableHLO to LinAlg_



#### Options
```
-enable-primitive-ops : Lower to primitive Linalg ops (map, reduce and transpose) when possible, instead of linalg.generic
Expand Down
7 changes: 7 additions & 0 deletions docs/generated/stablehlo_passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

_Legalizes from CHLO ops flow to StableHLO and Shape ops_


### `-shape-legalize-to-stablehlo`

_Legalize shape-related ops to StableHLO._
Expand All @@ -17,6 +18,7 @@ compilation pipelines that use StableHLO operations to model dynamism.
_Folds StableHLO operations_



#### Options
```
-fold-float : Allow for potentially lossy computations using float type.
Expand All @@ -25,6 +27,7 @@ _Folds StableHLO operations_

_Canonicalizes StableHLO operations_


### `-stablehlo-canonicalize-dynamism`

_Canonicalizes dynamic StableHLO ops into static ops._
Expand Down Expand Up @@ -87,6 +90,7 @@ func.func @tan_op_non_complex(%arg0: tensor<4xf64>) -> tensor<4xf64> {

_Pass to transform the IR to be on signless integers._


### `-stablehlo-legalize-composite-to-call`

_Replaces composite ops with a call to their decomposition._
Expand Down Expand Up @@ -232,6 +236,7 @@ func.func @add(%arg0: tensor<!quant.uniform<i8:f32, 1.000000e+00>>, %arg1: tenso

_Legalize StableHLO to VHLO._


### `-stablehlo-refine-arguments`

_Refines the argument shapes of the main function._
Expand Down Expand Up @@ -293,11 +298,13 @@ static shapes throughout the program.

_Legalize VHLO to StableHLO._


### `-vhlo-to-version`

_Convert between versions of VHLO._



#### Options
```
-target : The target version. Must be a version of the form #.#.# .
Expand Down
1 change: 1 addition & 0 deletions docs/generated/stablehlo_tosa_passes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

_Legalize StableHLO to TOSA_


### `-stablehlo-prepare-for-tosa`

_Prepare StableHLO for legalization to TOSA_
Expand Down
19 changes: 9 additions & 10 deletions stablehlo/conversions/linalg/transforms/TypeConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,35 @@ Type convertShapedType(ShapedType shapedType) {
return shapedType;
}

std::optional<Value> 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<UnrealizedConversionCastOp>(loc, type, inputs[0])
->getResult(0);
}

std::optional<Value> 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<UnrealizedConversionCastOp>(loc, type, inputs[0])
->getResult(0);
}

std::optional<Value> scalarToTensor(OpBuilder &builder, Type type,
ValueRange inputs, Location loc) {
Value scalarToTensor(OpBuilder &builder, Type type, ValueRange inputs,
Location loc) {
assert(inputs.size() == 1);
if (mlir::isa<ShapedType>(inputs.front().getType())) {
return std::nullopt;
return Value();
}
Value result =
builder
Expand Down

0 comments on commit 6e403b1

Please sign in to comment.