Skip to content

Commit d5107aa

Browse files
authored
despecialize generic create_result method (#2783)
* despecialize generic `create_result` method * fix test * change typeof to Core.Typeof
1 parent e1f0382 commit d5107aa

2 files changed

Lines changed: 17 additions & 15 deletions

File tree

src/Compiler.jl

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ function traced_setfield_buffer!(
218218
return traced_setfield!(obj, field, cval, path)
219219
end
220220

221-
function create_result(
222-
tocopy::T,
223-
path,
221+
Base.@nospecializeinfer function create_result(
222+
@nospecialize(tocopy),
223+
@nospecialize(path::Tuple),
224224
result_stores,
225225
path_to_shard_info,
226226
to_unreshard_results,
@@ -230,11 +230,13 @@ function create_result(
230230
result_cache,
231231
var_idx,
232232
resultgen_code,
233-
) where {T}
233+
)
234234
if !isstructtype(typeof(tocopy))
235235
error("cannot copy $tocopy of type $(Core.Typeof(tocopy))")
236236
end
237237

238+
T = Core.Typeof(tocopy)
239+
238240
args = (
239241
result_stores,
240242
path_to_shard_info,
@@ -277,7 +279,7 @@ end
277279

278280
function create_result(
279281
tocopy::ConcretePJRTNumber{T,D},
280-
path,
282+
@nospecialize(path::Tuple),
281283
result_stores,
282284
path_to_shard_info,
283285
to_unreshard_results,
@@ -319,7 +321,7 @@ end
319321

320322
function create_result(
321323
tocopy::ConcreteIFRTNumber{T},
322-
path,
324+
@nospecialize(path::Tuple),
323325
result_stores,
324326
path_to_shard_info,
325327
to_unreshard_results,
@@ -361,7 +363,7 @@ end
361363

362364
function create_result(
363365
tocopy::ConcretePJRTArray{T,N,D},
364-
path,
366+
@nospecialize(path::Tuple),
365367
result_stores,
366368
path_to_shard_info,
367369
to_unreshard_results,
@@ -404,7 +406,7 @@ end
404406

405407
function create_result(
406408
tocopy::ConcreteIFRTArray{T,N},
407-
path,
409+
@nospecialize(path::Tuple),
408410
result_stores,
409411
path_to_shard_info,
410412
to_unreshard_results,
@@ -490,7 +492,7 @@ end
490492

491493
function create_result(
492494
tocopy::Array{T,N},
493-
path,
495+
@nospecialize(path::Tuple),
494496
result_stores,
495497
path_to_shard_info,
496498
to_unreshard_results,
@@ -542,7 +544,7 @@ end
542544

543545
function create_result(
544546
tocopy::Tuple,
545-
path,
547+
@nospecialize(path::Tuple),
546548
result_stores,
547549
path_to_shard_info,
548550
to_unreshard_results,
@@ -573,7 +575,7 @@ end
573575

574576
function create_result(
575577
tocopy::NamedTuple{K,T},
576-
path,
578+
@nospecialize(path::Tuple),
577579
result_stores,
578580
path_to_shard_info,
579581
to_unreshard_results,
@@ -604,7 +606,7 @@ end
604606

605607
function create_result(
606608
tocopy::D,
607-
path,
609+
@nospecialize(path::Tuple),
608610
result_stores,
609611
path_to_shard_info,
610612
to_unreshard_results,
@@ -661,7 +663,7 @@ end
661663

662664
function create_result(
663665
tocopy::Reactant.XLA.AbstractDevice,
664-
_path,
666+
@nospecialize(_path::Tuple),
665667
_result_stores,
666668
_path_to_shard_info,
667669
_to_unreshard_results,
@@ -677,7 +679,7 @@ end
677679

678680
function create_result(
679681
tocopy::Union{Integer,AbstractFloat,AbstractString,Nothing,Type,Symbol,Char},
680-
_path,
682+
@nospecialize(_path::Tuple),
681683
_result_stores,
682684
_path_to_shard_info,
683685
_to_unreshard_results,

test/core/compile.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ end
195195

196196
function Reactant.Compiler.create_result(
197197
tocopy::MockTestCustomPath,
198-
path,
198+
path::Tuple,
199199
result_stores,
200200
path_to_shard_info,
201201
to_unreshard_results,

0 commit comments

Comments
 (0)