Skip to content

Commit 5621e39

Browse files
authored
Merge pull request #37 from arhik/main
[docs] update ops/clamp.jl
2 parents 290aed1 + c627cfb commit 5621e39

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/ops/clamp.jl

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
export clamp_kernel, clamp
2+
3+
"""
4+
clamp_kernel(x::WgpuArray{T, N}, out::WgpuArray{T, N}, minVal::T, maxval::T) where {T, N}
5+
This is a clamp compute kernel which takes input `x` and an uninitialized output `out` WgpuArrays,
6+
along with clamp lower bound and upper bound values `minVal` and `maxVal` of type `T`. End users are not
7+
supposed to call this function like regular julia function. This is instead needs to passed to `@wgpukernel`
8+
macro to under go transformations into `WGSL` shader code.
9+
"""
10+
111
function clamp_kernel(x::WgpuArray{T, N}, out::WgpuArray{T, N}, minval::T, maxval::T) where {T, N}
212
gId = xDims.x*globalId.y + globalId.x
313
value = x[gId]
414
out[gId] = clamp(value, minval, maxval)
515
end
616

7-
17+
"""
18+
clamp(x::WgpuArray{T, N}, minValue::T, maxValue::T) where {T, N}
19+
This is a clamp operator which takes `WgpuArray` as an input along with lower bound and upper bound clamp
20+
values to clamp the input array to these bounds
21+
"""
822
function clamp(x::WgpuArray{T, N}, minValue::T, maxValue::T) where {T, N}
923
y = similar(x)
1024
@wgpukernel launch=true workgroupSizes=(4, 4) workgroupCount=(2, 2) shmem=() clamp_kernel(x, y, minValue, maxValue)

0 commit comments

Comments
 (0)