[PYTHON] Now providing triton.next_power_of_2 (#273)
This commit is contained in:
@@ -833,6 +833,16 @@ def jit(fn):
|
||||
def cdiv(x, y):
|
||||
return (x + y - 1) // y
|
||||
|
||||
def next_power_of_2(n):
|
||||
"""Return the smallest power of 2 greater than or equal to n"""
|
||||
n -= 1
|
||||
n |= n >> 1
|
||||
n |= n >> 2
|
||||
n |= n >> 4
|
||||
n |= n >> 8
|
||||
n |= n >> 16
|
||||
n += 1
|
||||
return n
|
||||
|
||||
######
|
||||
|
||||
|
Reference in New Issue
Block a user