@@ -29,7 +29,7 @@ function layer_norm_fwd(X::ct.TileArray{Float32, 2}, W::ct.TileArray{Float32, 1}
2929 N = size (X, 2 )
3030
3131 # Compute mean
32- mean = ct . full ( (1 , TILE_N), 0.0f0 , Float32 )
32+ mean = zeros (Float32, (1 , TILE_N))
3333 j = Int32 (1 )
3434 while j <= num_tiles
3535 tx = ct. load (X, (bid_m, j), (1 , TILE_N); padding_mode= ct. PaddingMode. Zero)
@@ -40,12 +40,12 @@ function layer_norm_fwd(X::ct.TileArray{Float32, 2}, W::ct.TileArray{Float32, 1}
4040 ct. store (Mean, bid_m, mean)
4141
4242 # Compute variance
43- var = ct . full ( (1 , TILE_N), 0.0f0 , Float32 )
43+ var = zeros (Float32, (1 , TILE_N))
4444 j = Int32 (1 )
4545 while j <= num_tiles
4646 tx = ct. load (X, (bid_m, j), (1 , TILE_N); padding_mode= ct. PaddingMode. Zero)
4747 # Mask for valid elements
48- mask = reshape (((j - Int32 (1 )) * Int32 (TILE_N) .+ ct. arange (( TILE_N,) , Int32)) .<= N, (1 , TILE_N))
48+ mask = reshape (((j - Int32 (1 )) * Int32 (TILE_N) .+ ct. arange (TILE_N, Int32)) .<= N, (1 , TILE_N))
4949 centered_tx = ifelse .(mask, tx .- mean, 0.0f0 )
5050 var = var .+ (centered_tx .^ 2.0f0 )
5151 j += Int32 (1 )
@@ -93,7 +93,7 @@ bid_m and j are 1-indexed (block ID and tile index).
9393 wdy = tw .* tdy
9494
9595 # Mask for valid elements
96- indices = ct. arange (( TILE_N,) , Int32)
96+ indices = ct. arange (TILE_N, Int32)
9797 offset = (j - Int32 (1 )) * Int32 (TILE_N)
9898 global_indices = offset .+ indices
9999 mask = reshape (global_indices .<= N, (1 , TILE_N))
@@ -131,8 +131,8 @@ function layer_norm_bwd_dx(DX::ct.TileArray{Float32, 2}, DY::ct.TileArray{Float3
131131 rstd = ct. load (Rstd, bid_m, (1 ,); padding_mode= ct. PaddingMode. Zero)
132132
133133 # First pass: compute c1 and c2 reduction terms
134- c1 = ct . full ( (1 , TILE_N), 0.0f0 , Float32 )
135- c2 = ct . full ( (1 , TILE_N), 0.0f0 , Float32 )
134+ c1 = zeros (Float32, (1 , TILE_N))
135+ c2 = zeros (Float32, (1 , TILE_N))
136136 j = Int32 (1 )
137137 while j <= num_tiles
138138 _, xhat, wdy = bwd_helper (X, W, DY, bid_m, j, mean, rstd, TILE_N, N)
@@ -190,8 +190,8 @@ function layer_norm_bwd_dx_partial_dwdb(DX::ct.TileArray{Float32, 2}, DY::ct.Til
190190 rstd = ct. load (Rstd, bid_m, (1 ,); padding_mode= ct. PaddingMode. Zero)
191191
192192 # First pass: compute c1 and c2 reduction terms
193- c1 = ct . full ( (1 , TILE_N), 0.0f0 , Float32 )
194- c2 = ct . full ( (1 , TILE_N), 0.0f0 , Float32 )
193+ c1 = zeros (Float32, (1 , TILE_N))
194+ c2 = zeros (Float32, (1 , TILE_N))
195195 j = Int32 (1 )
196196 while j <= num_tiles
197197 _, xhat, wdy = bwd_helper (X, W, DY, bid_m, j, mean, rstd, TILE_N, N)
@@ -253,8 +253,8 @@ function layer_norm_bwd_dwdb(DW::ct.TileArray{Float32, 2}, DB::ct.TileArray{Floa
253253 bid_n = ct. bid (1 )
254254 num_tiles = ct. num_tiles (DW, 2 , (TILE_N, TILE_M))
255255
256- dw = ct . zeros ((TILE_N, TILE_M), Float32 )
257- db = ct . zeros ((TILE_N, TILE_M), Float32 )
256+ dw = zeros (Float32, (TILE_N, TILE_M))
257+ db = zeros (Float32, (TILE_N, TILE_M))
258258 i = Int32 (1 )
259259 while i <= num_tiles
260260 dw = dw .+ ct. load (DW, (bid_n, i), (TILE_N, TILE_M); padding_mode= ct. PaddingMode. Zero)
0 commit comments