Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly gensym shim templates in p_accessors #642

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/arraymancer/tensor/private/p_accessors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ template stridedIteration*(strider: IterKind, t, iter_offset, iter_size: typed):
when getSubType(type(t)) is KnownSupportsCopyMem:
let data = t.unsafe_raw_offset()
else:
template data: untyped = t
template data: untyped {.gensym.} = t

# Optimize for loops in contiguous cases
if t.is_C_contiguous:
Expand All @@ -194,7 +194,7 @@ template stridedCoordsIteration*(t, iter_offset, iter_size: typed): untyped =
when getSubType(type(t)) is KnownSupportsCopyMem:
let data = t.unsafe_raw_offset()
else:
template data: untyped = t
template data: untyped {.gensym.} = t
let rank = t.rank

initStridedIteration(coord, backstrides, iter_pos, t, iter_offset, iter_size)
Expand All @@ -217,11 +217,11 @@ template dualStridedIteration*(strider: IterKind, t1, t2, iter_offset, iter_size
when getSubType(type(t1)) is KnownSupportsCopyMem:
let t1data = t1.unsafe_raw_offset()
else:
template t1data: untyped = t1
template t1data: untyped {.gensym.} = t1
when getSubType(type(t2)) is KnownSupportsCopyMem:
let t2data = t2.unsafe_raw_offset()
else:
template t2data: untyped = t2
template t2data: untyped {.gensym.} = t2

# Optimize for loops in contiguous cases
if t1_contiguous and t2_contiguous:
Expand Down Expand Up @@ -262,15 +262,15 @@ template tripleStridedIteration*(strider: IterKind, t1, t2, t3, iter_offset, ite
when getSubType(type(t1)) is KnownSupportsCopyMem:
let t1data = t1.unsafe_raw_offset()
else:
template t1data: untyped = t1
template t1data: untyped {.gensym.} = t1
when getSubType(type(t2)) is KnownSupportsCopyMem:
let t2data = t2.unsafe_raw_offset()
else:
template t2data: untyped = t2
template t2data: untyped {.gensym.} = t2
when getSubType(type(t3)) is KnownSupportsCopyMem:
let t3data = t3.unsafe_raw_offset()
else:
template t3data: untyped = t3
template t3data: untyped {.gensym.} = t3

# Optimize for loops in contiguous cases
# Note that not all cases are handled here, just some probable ones
Expand Down
Loading