masahi commented on a change in pull request #7611:
URL: https://github.com/apache/tvm/pull/7611#discussion_r591921822
##########
File path: python/tvm/topi/cuda/sort.py
##########
@@ -121,41 +221,85 @@ def _sort_common(
## On the final iteration of the algorithm, one thread will merge two
sorted lists
## to sort the entire array
- max_threads =
int(tvm.target.Target.current(allow_none=False).max_num_threads)
- nthread_tx = max_threads
- nthread_bx = ceil_div(size, max_threads)
- nthread_by = axis_mul_before
- nthread_bz = axis_mul_after
-
- def compare(a, b):
- """
- Compare a and b in proper ascending or descending order
- """
- if is_ascend:
- out = a <= b
- else:
- out = b <= a
- return out
-
- def bottom_up_merge(source, dest, source_idx, dest_idx, start, middle,
end, even):
- """
- Merge the two sections of the array assigned to this thread
- """
- # pylint: disable=arguments-out-of-order
- # initialize iterators
- i = ib.allocate("int64", (1,), name="i", scope="local")
- j = ib.allocate("int64", (1,), name="j", scope="local")
- i[0] = start
- j[0] = middle
- # set up indexes
- base_idx = by * size * axis_mul_after + bz
- # iterate over the output loop
- with ib.for_range(0, end - start) as k:
- i_idx = base_idx + i[0] * axis_mul_after
- j_idx = base_idx + j[0] * axis_mul_after
- k_idx = base_idx + (k + start) * axis_mul_after
+ with ib.if_scope(size > 0):
Review comment:
maybe better to move this outside of `_sort_common`? To make indent not
going too deep.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]