Skip to content

Commit 563b0e8

Browse files
Regenerate MLIR Bindings (#1710)
Co-authored-by: enzyme-ci-bot[bot] <78882869+enzyme-ci-bot[bot]@users.noreply.github.com>
1 parent 5c6a34d commit 563b0e8

File tree

5 files changed

+545
-42
lines changed

5 files changed

+545
-42
lines changed

src/mlir/Dialects/Enzyme.jl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,40 @@ function autodiff(
175175
)
176176
end
177177

178+
function autodiff_region(
179+
inputs::Vector{Value};
180+
outputs::Vector{IR.Type},
181+
activity,
182+
ret_activity,
183+
width=nothing,
184+
strong_zero=nothing,
185+
fn=nothing,
186+
body::Region,
187+
location=Location(),
188+
)
189+
op_ty_results = IR.Type[outputs...,]
190+
operands = Value[inputs...,]
191+
owned_regions = Region[body,]
192+
successors = Block[]
193+
attributes = NamedAttribute[
194+
namedattribute("activity", activity), namedattribute("ret_activity", ret_activity)
195+
]
196+
!isnothing(width) && push!(attributes, namedattribute("width", width))
197+
!isnothing(strong_zero) && push!(attributes, namedattribute("strong_zero", strong_zero))
198+
!isnothing(fn) && push!(attributes, namedattribute("fn", fn))
199+
200+
return create_operation(
201+
"enzyme.autodiff_region",
202+
location;
203+
operands,
204+
owned_regions,
205+
successors,
206+
attributes,
207+
results=op_ty_results,
208+
result_inference=false,
209+
)
210+
end
211+
178212
function batch(
179213
inputs::Vector{Value}; outputs::Vector{IR.Type}, fn, batch_shape, location=Location()
180214
)
@@ -648,4 +682,23 @@ function untracedCall(
648682
)
649683
end
650684

685+
function yield(operands::Vector{Value}; location=Location())
686+
op_ty_results = IR.Type[]
687+
operands = Value[operands...,]
688+
owned_regions = Region[]
689+
successors = Block[]
690+
attributes = NamedAttribute[]
691+
692+
return create_operation(
693+
"enzyme.yield",
694+
location;
695+
operands,
696+
owned_regions,
697+
successors,
698+
attributes,
699+
results=op_ty_results,
700+
result_inference=false,
701+
)
702+
end
703+
651704
end # enzyme

src/mlir/Dialects/Gpu.jl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2729,6 +2729,48 @@ function spmat_get_size(
27292729
)
27302730
end
27312731

2732+
"""
2733+
`subgroup_broadcast`
2734+
2735+
Broadcasts a value from one lane to all active lanes in a subgroup. The
2736+
result is guaranteed to be uniform across the active lanes in subgroup.
2737+
2738+
The possible broadcast types are:
2739+
2740+
* `first_active_lane` - broadcasts the value from the first active lane
2741+
in the subgroup.
2742+
* `specific_lane` - broadcasts from the specified lane. The lane index
2743+
must be uniform and within the subgroup size. The result is poison if the
2744+
lane index is invalid, non subgroup-uniform, or if the source lane is not
2745+
active.
2746+
"""
2747+
function subgroup_broadcast(
2748+
src::Value,
2749+
lane=nothing::Union{Nothing,Value};
2750+
result=nothing::Union{Nothing,IR.Type},
2751+
broadcast_type,
2752+
location=Location(),
2753+
)
2754+
op_ty_results = IR.Type[]
2755+
operands = Value[src,]
2756+
owned_regions = Region[]
2757+
successors = Block[]
2758+
attributes = NamedAttribute[namedattribute("broadcast_type", broadcast_type),]
2759+
!isnothing(lane) && push!(operands, lane)
2760+
!isnothing(result) && push!(op_ty_results, result)
2761+
2762+
return create_operation(
2763+
"gpu.subgroup_broadcast",
2764+
location;
2765+
operands,
2766+
owned_regions,
2767+
successors,
2768+
attributes,
2769+
results=(length(op_ty_results) == 0 ? nothing : op_ty_results),
2770+
result_inference=(length(op_ty_results) == 0 ? true : false),
2771+
)
2772+
end
2773+
27322774
"""
27332775
`subgroup_id`
27342776

src/mlir/Dialects/Llvm.jl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,22 @@ Examples:
14591459
// Alignment is optional
14601460
llvm.mlir.global private constant @y(dense<1.0> : tensor<8xf32>) { alignment = 32 : i64 } : !llvm.array<8 x f32>
14611461
```
1462+
1463+
The `target_specific_attrs` attribute provides a mechanism to preserve
1464+
target-specific LLVM IR attributes that are not explicitly modeled in the
1465+
LLVM dialect.
1466+
1467+
The attribute is an array containing either string attributes or
1468+
two-element array attributes of strings. The value of a standalone string
1469+
attribute is interpreted as the name of an LLVM IR attribute on the global.
1470+
A two-element array is interpreted as a key-value pair.
1471+
1472+
# Example
1473+
1474+
```mlir
1475+
llvm.mlir.global external @example() {
1476+
target_specific_attrs = [\"value-less-attr\", [\"int-attr\", \"4\"], [\"string-attr\", \"string\"]]} : f64
1477+
```
14621478
"""
14631479
function mlir_global(;
14641480
global_type,
@@ -1476,6 +1492,7 @@ function mlir_global(;
14761492
comdat=nothing,
14771493
dbg_exprs=nothing,
14781494
visibility_=nothing,
1495+
target_specific_attrs=nothing,
14791496
initializer::Region,
14801497
location=Location(),
14811498
)
@@ -1503,6 +1520,8 @@ function mlir_global(;
15031520
!isnothing(comdat) && push!(attributes, namedattribute("comdat", comdat))
15041521
!isnothing(dbg_exprs) && push!(attributes, namedattribute("dbg_exprs", dbg_exprs))
15051522
!isnothing(visibility_) && push!(attributes, namedattribute("visibility_", visibility_))
1523+
!isnothing(target_specific_attrs) &&
1524+
push!(attributes, namedattribute("target_specific_attrs", target_specific_attrs))
15061525

15071526
return create_operation(
15081527
"llvm.mlir.global",
@@ -1933,7 +1952,6 @@ function func(;
19331952
unsafe_fp_math=nothing,
19341953
no_infs_fp_math=nothing,
19351954
no_nans_fp_math=nothing,
1936-
approx_func_fp_math=nothing,
19371955
no_signed_zeros_fp_math=nothing,
19381956
denormal_fp_math=nothing,
19391957
denormal_fp_math_f32=nothing,
@@ -2014,8 +2032,6 @@ function func(;
20142032
push!(attributes, namedattribute("no_infs_fp_math", no_infs_fp_math))
20152033
!isnothing(no_nans_fp_math) &&
20162034
push!(attributes, namedattribute("no_nans_fp_math", no_nans_fp_math))
2017-
!isnothing(approx_func_fp_math) &&
2018-
push!(attributes, namedattribute("approx_func_fp_math", approx_func_fp_math))
20192035
!isnothing(no_signed_zeros_fp_math) && push!(
20202036
attributes, namedattribute("no_signed_zeros_fp_math", no_signed_zeros_fp_math)
20212037
)

0 commit comments

Comments
 (0)