Skip to content

Commit

Permalink
Less restack
Browse files Browse the repository at this point in the history
  • Loading branch information
tkf committed Jan 29, 2022
1 parent aad1841 commit 6f84d81
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/AutoObjectsReStacker.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ restack
_getlength(::Type{<:NTuple{N,Any}}) where N = N
_getnames(::Type{<:NamedTuple{names}}) where names = names

# Not using dispatch, to check `issingletontype` first.
# Not using dispatch, to check `datatype_pointerfree` first.
@generated function restack(x)
if Base.issingletontype(x)
ex = x.instance :: x
if isconcretetype(x) && Base.datatype_pointerfree(x)
# With FoldsCUDA, we need to inline everything. So, let's try minimizing
# inline cost by avoiding unnecessary recursions:
ex = :x
elseif x <: Tuple
N = _getlength(x)
ex = :(($(map(i -> :(restack(x[$i])), 1:N)...),))
Expand Down

0 comments on commit 6f84d81

Please sign in to comment.