|
12 | 12 |
|
13 | 13 | import cuda.parallel.experimental.algorithms as algorithms |
14 | 14 | import cuda.parallel.experimental.iterators as iterators |
15 | | -from cuda.parallel.experimental.struct import gpu_struct |
16 | 15 |
|
17 | 16 |
|
18 | 17 | def random_int(shape, dtype): |
@@ -551,30 +550,3 @@ def binary_op(x, y): |
551 | 550 | d_in = cp.zeros(size)[::2] |
552 | 551 | with pytest.raises(ValueError, match="Non-contiguous arrays are not supported."): |
553 | 552 | _ = algorithms.reduce_into(d_in, d_out, binary_op, h_init) |
554 | | - |
555 | | - |
556 | | -def test_reduce_struct_type(): |
557 | | - @gpu_struct |
558 | | - class Pixel: |
559 | | - r: np.int32 |
560 | | - g: np.int32 |
561 | | - b: np.int32 |
562 | | - |
563 | | - def max_g_value(x, y): |
564 | | - return x if x.g > y.g else y |
565 | | - |
566 | | - d_rgb = cp.random.randint(0, 256, (10, 3), dtype=np.int32).view(Pixel.dtype) |
567 | | - d_out = cp.empty(1, Pixel.dtype) |
568 | | - |
569 | | - h_init = Pixel(0, 0, 0) |
570 | | - |
571 | | - reduce_into = algorithms.reduce_into(d_rgb, d_out, max_g_value, h_init) |
572 | | - temp_storage_bytes = reduce_into(None, d_rgb, d_out, len(d_rgb), h_init) |
573 | | - |
574 | | - d_temp_storage = cp.empty(temp_storage_bytes, dtype=np.uint8) |
575 | | - _ = reduce_into(d_temp_storage, d_rgb, d_out, len(d_rgb), h_init) |
576 | | - |
577 | | - h_rgb = d_rgb.get() |
578 | | - expected = h_rgb[h_rgb.view("int32")[:, 1].argmax()] |
579 | | - |
580 | | - np.testing.assert_equal(expected["g"], d_out.get()["g"]) |
0 commit comments