[Python | GPU] Reduce operation fails code generation on GPU
- Dominant language
- Python
- Stars
- 593
- Forks
- 163
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 60
Description
*Tested only in DaCe v1*
The following code should work
```python
import dace
import cupy as cp
import numpy as np
@dace.program
def multidimred(a, b):
b[:] = np.sum(a, axis=(0, 1))
a = cp.random.rand(2, 2, 6)
b = cp.random.rand(6)
multidimred(a, b)
```
but it dies in codegen:
```
File "/home/fgdeconi/work/git/ndsl/external/dace/dace/codegen/dispatcher.py", line 466, in dispatch_scope
self._map_dispatchers[map_schedule].generate_scope(sdfg, cfg, sub_dfg, state_id, function_stream,
File "/home/fgdeconi/work/git/ndsl/external/dace/dace/codegen/targets/cuda.py", line 1656, in generate_scope
cudastream = '__state->gpu_context->streams[%d]' % scope_entry._cuda_stream
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'MapEntry' object has no attribute '_cuda_stream'
```
There's [a unit test](https://github.com/spcl/dace/blob/d99ad29c417ff33adc310320bb382df32573aa79/tests/library/reduce_test.py#L70) testing this exact code. But the test doesn't call the `program` directly, instead it runs
```python
sdfg = multidimred.to_sdfg(a, b)
sdfg.apply_gpu_transformations()
```
which, indeed fixes the present issue, but arguably shouldn't be needed.
PS: The `cupy.max` is not supported.
Contributor guide
Assessment
This issue has not been assessed yet.