Skip to content

Commit 7399864

Browse files
Regenerate MLIR Bindings (#1797)
Co-authored-by: enzyme-ci-bot[bot] <78882869+enzyme-ci-bot[bot]@users.noreply.github.com>
1 parent 158b986 commit 7399864

File tree

7 files changed

+298
-30
lines changed

7 files changed

+298
-30
lines changed

src/mlir/Dialects/Arith.jl

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,17 +1601,30 @@ broadcasted to `<dim1 x dim2 x dim3 ... (dimN/blockSize) x blockSize>`. Note
16011601
that there could be multiple quantization axes. Internally,
16021602
`arith.scaling_extf` would perform the following:
16031603
1604-
```
1605-
resultTy = get_type(result)
1606-
scaleTy = get_type(scale)
1607-
inputTy = get_type(input)
1608-
scale.exponent = arith.truncf(scale) : scaleTy to f8E8M0
1609-
scale.extf = arith.extf(scale.exponent) : f8E8M0 to resultTy
1610-
input.extf = arith.extf(input) : inputTy to resultTy
1611-
result = arith.mulf(scale.extf, input.extf)
1612-
```
1613-
It propagates NaN values. Therefore, if either scale or the input element
1614-
contains NaN, then the output element value will also be a NaN.
1604+
```mlir
1605+
// Cast scale to result type.
1606+
%0 = arith.truncf %1 : f32 to f8E8M0FNU
1607+
%1 = arith.extf %0 : f8E8M0FNU to f16
1608+
1609+
// Cast input to result type.
1610+
%2 = arith.extf %3 : f4E2M1FN to f16
1611+
1612+
// Perform scaling
1613+
%3 = arith.mulf %2, %1 : f16
1614+
```
1615+
It propagates NaN values. Therefore, if either scale or the input element
1616+
contains NaN, then the output element value will also be a NaN.
1617+
1618+
# Example
1619+
1620+
```mlir
1621+
// Upcast from f4E2M1FN to f32.
1622+
%a = arith.scaling_extf %b, %c : f4E2M1FN, f8E8M0FNU to f32
1623+
1624+
// Element-wise upcast with broadcast (blockSize = 32).
1625+
%f = vector.broadcast %g : vector<1xf8E8M0FNU> to vector<32xf8E8M0FNU>
1626+
%h = arith.scaling_extf %i, %f : vector<32xf4E2M1FN>, vector<32xf8E8M0FNU> to vector<32xbf16>
1627+
```
16151628
"""
16161629
function scaling_extf(
16171630
in::Value, scale::Value; out::IR.Type, fastmath=nothing, location=Location()
@@ -1662,14 +1675,27 @@ broadcasted to `<dim1 x dim2 x dim3 ... (dimN/blockSize) x blockSize>`. Note
16621675
that there could be multiple quantization axes. Internally,
16631676
`arith.scaling_truncf` would perform the following:
16641677
1678+
```mlir
1679+
// Cast scale to input type.
1680+
%0 = arith.truncf %1 : f32 to f8E8M0FNU
1681+
%1 = arith.extf %0 : f8E8M0FNU to f16
1682+
1683+
// Perform scaling.
1684+
%3 = arith.divf %2, %1 : f16
1685+
1686+
// Cast to result type.
1687+
%4 = arith.truncf %3 : f16 to f4E2M1FN
16651688
```
1666-
scaleTy = get_type(scale)
1667-
inputTy = get_type(input)
1668-
resultTy = get_type(result)
1669-
scale.exponent = arith.truncf(scale) : scaleTy to f8E8M0
1670-
scale.extf = arith.extf(scale.exponent) : f8E8M0 to inputTy
1671-
result = arith.divf(input, scale.extf)
1672-
result.cast = arith.truncf(result, resultTy)
1689+
1690+
# Example
1691+
1692+
```mlir
1693+
// Downcast from f32 to f4E2M1FN.
1694+
%a = arith.scaling_truncf %b, %c : f32, f8E8M0FNU to f4E2M1FN
1695+
1696+
// Element-wise downcast with broadcast (blockSize = 32).
1697+
%f = vector.broadcast %g : vector<1xf8E8M0FNU> to vector<32xf8E8M0FNU>
1698+
%h = arith.scaling_truncf %i, %f : vector<32xbf16>, vector<32xf8E8M0FNU> to vector<32xf4E2M1FN>
16731699
```
16741700
"""
16751701
function scaling_truncf(

src/mlir/Dialects/EnzymeXLA.jl

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ function barrier(indices::Vector{Value}; location=Location())
7272
)
7373
end
7474

75+
function cacheload(
76+
memref::Value, indices::Vector{Value}; result::IR.Type, location=Location()
77+
)
78+
op_ty_results = IR.Type[result,]
79+
operands = Value[memref, indices...]
80+
owned_regions = Region[]
81+
successors = Block[]
82+
attributes = NamedAttribute[]
83+
84+
return create_operation(
85+
"enzymexla.cacheload",
86+
location;
87+
operands,
88+
owned_regions,
89+
successors,
90+
attributes,
91+
results=op_ty_results,
92+
result_inference=false,
93+
)
94+
end
95+
7596
function comm_region(; result_0::Vector{IR.Type}, body::Region, location=Location())
7697
op_ty_results = IR.Type[result_0...,]
7798
operands = Value[]
@@ -240,8 +261,8 @@ end
240261
`gpu_wrapper`
241262
242263
The optional arguments to this operation are suggestions about what block
243-
dimensions this gpu kernel should have - usually taken from kernel launch
244-
params
264+
dimensions this gpu kernel should have - usually taken f rom kernel
265+
launch params
245266
"""
246267
function gpu_wrapper(
247268
blockDims::Vector{Value}; result::IR.Type, region::Region, location=Location()
@@ -327,10 +348,12 @@ end
327348
328349
This operation computes the QR factorization of a matrix using Householder
329350
reflections. Mathematically, it decomposes A into the product of an
330-
orthogonal matrix Q and an upper triangular matrix R, such that A = QR.
351+
orthogonal matri x Q and an upper triangular matrix R,
352+
such that A = QR.
331353
332-
This operation is modeled after LAPACK\'s *GEQRF routines, which returns the
333-
result in the QR packed format.
354+
This operation is modeled after
355+
LAPACK\'s *GEQRF routines, which returns the result in
356+
the QR packed format.
334357
"""
335358
function lapack_geqrf(
336359
input::Value; output::IR.Type, tau::IR.Type, info::IR.Type, location=Location()
@@ -859,6 +882,25 @@ function stream2token(source::Value; result::IR.Type, location=Location())
859882
)
860883
end
861884

885+
function subindex(source::Value, index::Value; result::IR.Type, location=Location())
886+
op_ty_results = IR.Type[result,]
887+
operands = Value[source, index]
888+
owned_regions = Region[]
889+
successors = Block[]
890+
attributes = NamedAttribute[]
891+
892+
return create_operation(
893+
"enzymexla.subindex",
894+
location;
895+
operands,
896+
owned_regions,
897+
successors,
898+
attributes,
899+
results=op_ty_results,
900+
result_inference=false,
901+
)
902+
end
903+
862904
"""
863905
`lapack_symm`
864906
@@ -893,6 +935,25 @@ function lapack_symm(
893935
)
894936
end
895937

938+
function typeAlign(; result::IR.Type, source, location=Location())
939+
op_ty_results = IR.Type[result,]
940+
operands = Value[]
941+
owned_regions = Region[]
942+
successors = Block[]
943+
attributes = NamedAttribute[namedattribute("source", source),]
944+
945+
return create_operation(
946+
"enzymexla.typeAlign",
947+
location;
948+
operands,
949+
owned_regions,
950+
successors,
951+
attributes,
952+
results=op_ty_results,
953+
result_inference=false,
954+
)
955+
end
956+
896957
function wrap(
897958
operand::Value;
898959
result=nothing::Union{Nothing,IR.Type},

src/mlir/Dialects/Gpu.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ end
995995
This operation provides a memref pointer to the start of dynamic shared
996996
memory, often referred to as workgroup memory. It\'s important to note that
997997
this dynamic shared memory needs to be allocated at kernel launch. One can
998-
conveniently utilize `the dynamic_shared_memory_size` parameter of
998+
conveniently utilize the `dynamic_shared_memory_size` parameter of
999999
`gpu.launch` for this purpose.
10001000
10011001
Examples:

src/mlir/Dialects/Llvm.jl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,7 +1949,6 @@ function func(;
19491949
reciprocal_estimates=nothing,
19501950
prefer_vector_width=nothing,
19511951
target_features=nothing,
1952-
unsafe_fp_math=nothing,
19531952
no_infs_fp_math=nothing,
19541953
no_nans_fp_math=nothing,
19551954
no_signed_zeros_fp_math=nothing,
@@ -1960,6 +1959,7 @@ function func(;
19601959
instrument_function_exit=nothing,
19611960
no_inline=nothing,
19621961
always_inline=nothing,
1962+
inline_hint=nothing,
19631963
no_unwind=nothing,
19641964
will_return=nothing,
19651965
optimize_none=nothing,
@@ -2026,8 +2026,6 @@ function func(;
20262026
push!(attributes, namedattribute("prefer_vector_width", prefer_vector_width))
20272027
!isnothing(target_features) &&
20282028
push!(attributes, namedattribute("target_features", target_features))
2029-
!isnothing(unsafe_fp_math) &&
2030-
push!(attributes, namedattribute("unsafe_fp_math", unsafe_fp_math))
20312029
!isnothing(no_infs_fp_math) &&
20322030
push!(attributes, namedattribute("no_infs_fp_math", no_infs_fp_math))
20332031
!isnothing(no_nans_fp_math) &&
@@ -2050,6 +2048,7 @@ function func(;
20502048
!isnothing(no_inline) && push!(attributes, namedattribute("no_inline", no_inline))
20512049
!isnothing(always_inline) &&
20522050
push!(attributes, namedattribute("always_inline", always_inline))
2051+
!isnothing(inline_hint) && push!(attributes, namedattribute("inline_hint", inline_hint))
20532052
!isnothing(no_unwind) && push!(attributes, namedattribute("no_unwind", no_unwind))
20542053
!isnothing(will_return) && push!(attributes, namedattribute("will_return", will_return))
20552054
!isnothing(optimize_none) &&

0 commit comments

Comments
 (0)