Skip to content

Commit 9fdaf0a

Browse files
committed
Add _scalar_pos
1 parent 115bdd6 commit 9fdaf0a

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/sizes.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ function _setscalar!(x, value, sizes::Sizes, k::Int)
4949
return x[sizes.storage_offset[k]+1] = value
5050
end
5151

52+
"""
53+
_scalar_pos(sizes, k) -> Int
54+
55+
Tape index of node `k`'s single scalar slot. Useful when callers want to build
56+
a 1-element view onto `forward_storage`/`reverse_storage` to do a
57+
broadcast-style read or write that's safe on a GPU array.
58+
"""
59+
@inline _scalar_pos(sizes::Sizes, k::Int) = sizes.storage_offset[k] + 1
60+
5261
function _getindex(x, sizes::Sizes, k::Int, j)
5362
return x[sizes.storage_offset[k]+j]
5463
end

0 commit comments

Comments
 (0)