espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.div_up
Less than 1 minute
espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.div_up
espnet2.asr.transducer.rnnt_multi_blank.utils.rnnt_helper.div_up(x: int, y: int)
Computes the ceiling division of two integers.
This function takes two integers, x and y, and returns the result of dividing x by y, rounding up to the nearest whole number. This is useful in scenarios where you want to ensure that the result of a division operation does not fall short of the intended number of groups or buckets, especially in applications like batching or memory allocation.
- Parameters:
- x (int) – The numerator, an integer value that represents the total number to be divided.
- y (int) – The denominator, a positive integer value by which to divide x. It must not be zero.
- Returns: The ceiling result of the division of x by y.
- Return type: int
- Raises:ZeroDivisionError – If y is zero, as division by zero is undefined.
Examples
>>> div_up(5, 2)
3
>>> div_up(10, 3)
4
>>> div_up(7, 1)
7
>>> div_up(0, 5)
0
NOTE
This function is designed to be used in CUDA kernels and is decorated with @cuda.jit for that purpose. Ensure that this function is called within a proper CUDA context.