Skip to content

Commit a6b32db

Browse files
authored
fix: dicts are mutable (#1349)
1 parent f57817f commit a6b32db

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/Compiler.jl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,21 +2127,23 @@ function compile_mlir!(
21272127
)
21282128
end
21292129

2130-
const COMMON_COMPILE_OPTIONS = Dict{Symbol,Any}(
2131-
:optimize => true,
2132-
:no_nan => false,
2133-
:client => nothing,
2134-
:raise => false,
2135-
:raise_first => false,
2136-
:shardy_passes => :(:to_mhlo_shardings),
2137-
:assert_nonallocating => false,
2138-
:donated_args => :(:auto),
2139-
:transpose_propagate => :(:up),
2140-
:reshape_propagate => :(:up),
2141-
:optimize_then_pad => true,
2142-
:optimize_communications => true,
2143-
:cudnn_hlo_optimize => false,
2144-
)
2130+
function get_common_compile_options()
2131+
return Dict{Symbol,Any}(
2132+
:optimize => true,
2133+
:no_nan => false,
2134+
:client => nothing,
2135+
:raise => false,
2136+
:raise_first => false,
2137+
:shardy_passes => :(:to_mhlo_shardings),
2138+
:assert_nonallocating => false,
2139+
:donated_args => :(:auto),
2140+
:transpose_propagate => :(:up),
2141+
:reshape_propagate => :(:up),
2142+
:optimize_then_pad => true,
2143+
:optimize_communications => true,
2144+
:cudnn_hlo_optimize => false,
2145+
)
2146+
end
21452147

21462148
const COMMON_COMPILE_OPTIONS_DOCS = """
21472149
- `optimize`: Optimizations passes to run on the traced MLIR code. Valid types of values
@@ -2212,7 +2214,7 @@ See also [`@code_xla`](@ref), [`@code_mhlo`](@ref).
22122214
"""
22132215
macro code_hlo(args...)
22142216
compile_expr, (; compiled) = compile_call_expr(
2215-
__module__, compile_mlir, COMMON_COMPILE_OPTIONS, args...
2217+
__module__, compile_mlir, get_common_compile_options(), args...
22162218
)
22172219
#! format: off
22182220
return esc(
@@ -2237,7 +2239,7 @@ See also [`@code_xla`](@ref), [`@code_hlo`](@ref).
22372239
"""
22382240
macro code_mhlo(args...)
22392241
compile_expr, (; compiled) = compile_call_expr(
2240-
__module__, compile_xla, COMMON_COMPILE_OPTIONS, args...
2242+
__module__, compile_xla, get_common_compile_options(), args...
22412243
)
22422244
#! format: off
22432245
return esc(
@@ -2263,7 +2265,7 @@ See also [`@code_mhlo`](@ref), [`@code_hlo`](@ref).
22632265
"""
22642266
macro code_xla(args...)
22652267
compile_expr, (; compiled) = compile_call_expr(
2266-
__module__, compile_xla, COMMON_COMPILE_OPTIONS, args...
2268+
__module__, compile_xla, get_common_compile_options(), args...
22672269
)
22682270
#! format: off
22692271
return esc(
@@ -2290,7 +2292,7 @@ $(SYNC_DOCS)
22902292
See also [`@jit`](@ref), [`@code_hlo`](@ref), [`@code_mhlo`](@ref), [`@code_xla`](@ref).
22912293
"""
22922294
macro compile(args...)
2293-
default_options = merge(COMMON_COMPILE_OPTIONS, Dict{Symbol,Any}(:sync => false))
2295+
default_options = merge(get_common_compile_options(), Dict{Symbol,Any}(:sync => false))
22942296
return esc(first(compile_call_expr(__module__, compile, default_options, args...)))
22952297
end
22962298

@@ -2308,7 +2310,7 @@ $(SYNC_DOCS)
23082310
See also [`@compile`](@ref), [`@code_hlo`](@ref), [`@code_mhlo`](@ref), [`@code_xla`](@ref).
23092311
"""
23102312
macro jit(args...)
2311-
default_options = merge(COMMON_COMPILE_OPTIONS, Dict{Symbol,Any}(:sync => false))
2313+
default_options = merge(get_common_compile_options(), Dict{Symbol,Any}(:sync => false))
23122314
compile_expr, (; compiled, args) = compile_call_expr(
23132315
__module__, compile, default_options, args...
23142316
)

0 commit comments

Comments
 (0)