Skip to content
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
9 changes: 4 additions & 5 deletions src/tilegym/ops/cutile/activation/gelu.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,18 @@ def gelu_kernel_ct(

# Create offset tile
offsets = ct.add(ct.arange(BLOCK_SIZE, dtype=ct.int32), block_start) # new var
mask = ct.less(offsets, n_elements) # new var

# Load input data
x_tile = ct.gather(x, offsets) # new var
# Load input data with padding_value to handle out-of-bounds reads safely
x_tile = ct.gather(x, offsets, padding_value=0) # new var

# Compute GELU based on approximation mode
if approximate == GELU_TANH:
gelu_output = gelu_tanh_fwd_ct(x_tile, BLOCK_SIZE)
else: # GELU_EXACT
gelu_output = gelu_fwd_ct(x_tile, BLOCK_SIZE)

# Store result
ct.scatter(y, offsets, gelu_output)
# Store result with check_bounds to prevent out-of-bounds writes
ct.scatter(y, offsets, gelu_output, check_bounds=True)


# Wrapper class for autograd integration
Expand Down
Loading