@@ -144,29 +144,29 @@ def any_kernel_2(mid, out, MID_SIZE, BLOCK_MID: tl.constexpr):
144144def any (inp ):
145145 logger .debug ("GEMS ANY" )
146146 n_elements = inp .numel ()
147- block_size = min (
147+ block_size = max (
148148 triton .cdiv (get_block (n_elements ), cluster_num ),
149149 triton .cdiv (buf_len_per_core * core_num , 4 ),
150150 )
151+
151152 mid_size = triton .cdiv (n_elements , block_size )
152153 block_mid = triton .next_power_of_2 (mid_size )
153154
154155 if n_elements >= vector_size * thread_num :
155- # according to api, op == any, use max to calculate
156- inpf = inp . to ( torch . float )
157- midf = torch .empty ((mid_size ,), dtype = torch .float , device = inp .device )
158- outf = torch .empty ([], dtype = torch .float , device = inp .device )
156+ inp_uint8 = inp . view ( torch . uint8 )
157+
158+ mid = torch .empty ((mid_size ,), dtype = torch .uint8 , device = inp .device )
159+ out = torch .empty ([], dtype = torch .uint8 , device = inp .device )
159160
160161 with torch_device_fn .device (inp .device ):
161162 max_kernel_1 [(mid_size , 1 )](
162- inpf , midf , n_elements , block_size , buffer_size_limit = 2048
163+ inp_uint8 , mid , n_elements , block_size , buffer_size_limit = 2048
163164 )
164165 if mid_size == 1 :
165- return midf .to (torch .bool ).reshape ([])
166- max_kernel_2 [(1 , 1 )](
167- midf , outf , mid_size , block_mid , buffer_size_limit = 2048
168- )
169- out = outf .to (torch .bool )
166+ return mid .view (torch .bool ).reshape ([])
167+
168+ max_kernel_2 [(1 , 1 )](mid , out , mid_size , block_mid , buffer_size_limit = 2048 )
169+ out = out .view (torch .bool )
170170 else :
171171 mid = torch .empty ((mid_size ,), dtype = torch .bool , device = inp .device )
172172 out = torch .empty ([], dtype = torch .bool , device = inp .device )
0 commit comments