Skip to content

Commit

Permalink
Fix comments to refer to the proper lines in the code snippets in the…
Browse files Browse the repository at this point in the history
… docs
  • Loading branch information
NaderAlAwar committed Jan 9, 2025
1 parent 0a6bf9e commit d7bed4a
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions python/cuda_parallel/tests/test_reduce_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def add_op(a, b):
d_input = cp.array(values, dtype=np.int32)
d_output = cp.empty(1, dtype=np.int32)

# Create the iterator
iterator = iterators.CacheModifiedInputIterator(d_input, modifier="stream")
h_init = np.array([0], dtype=np.int32)
d_output = cp.empty(1, dtype=np.int32)
iterator = iterators.CacheModifiedInputIterator(
d_input, modifier="stream"
) # Input sequence
h_init = np.array([0], dtype=np.int32) # Initial value for the reduction
d_output = cp.empty(1, dtype=np.int32) # Storage for output

# Instantiate reduction, determine storage requirements, and allocate storage
reduce_into = algorithms.reduce_into(iterator, d_output, add_op, h_init)
Expand Down Expand Up @@ -87,10 +88,9 @@ def add_op(a, b):
value = 10
num_items = 3

# Create the iterator
constant_it = iterators.ConstantIterator(np.int32(value))
h_init = np.array([0], dtype=np.int32)
d_output = cp.empty(1, dtype=np.int32)
constant_it = iterators.ConstantIterator(np.int32(value)) # Input sequence
h_init = np.array([0], dtype=np.int32) # Initial value for the reduction
d_output = cp.empty(1, dtype=np.int32) # Storage for output

# Instantiate reduction, determine storage requirements, and allocate storage
reduce_into = algorithms.reduce_into(constant_it, d_output, add_op, h_init)
Expand Down Expand Up @@ -121,10 +121,9 @@ def add_op(a, b):
first_item = 10
num_items = 3

# Create the iterator
first_it = iterators.CountingIterator(np.int32(first_item))
h_init = np.array([0], dtype=np.int32)
d_output = cp.empty(1, dtype=np.int32)
first_it = iterators.CountingIterator(np.int32(first_item)) # Input sequence
h_init = np.array([0], dtype=np.int32) # Initial value for the reduction
d_output = cp.empty(1, dtype=np.int32) # Storage for output

# Instantiate reduction, determine storage requirements, and allocate storage
reduce_into = algorithms.reduce_into(first_it, d_output, add_op, h_init)
Expand Down Expand Up @@ -160,12 +159,11 @@ def square_op(a):
first_item = 10
num_items = 3

# Creating the iterator by composing with a CountingIterator
transform_it = iterators.TransformIterator(
iterators.CountingIterator(np.int32(first_item)), square_op
)
h_init = np.array([0], dtype=np.int32)
d_output = cp.empty(1, dtype=np.int32)
) # Input sequence
h_init = np.array([0], dtype=np.int32) # Initial value for the reduction
d_output = cp.empty(1, dtype=np.int32) # Storage for output

# Instantiate reduction, determine storage requirements, and allocate storage
reduce_into = algorithms.reduce_into(transform_it, d_output, add_op, h_init)
Expand Down

0 comments on commit d7bed4a

Please sign in to comment.