spcl / spcl/dace

Fill library node

Open
#1,576 7 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue libraries
Dominant language
Python
Stars
593
Forks
163
Avg merge
2d 23h
Merged PRs (30d)
60

Description

Filling an entire data container (like an array) with a single value is a common use case in DaCe codes. Instead of manually specifying _how_ a container should be filled, we would like to have a [Library Node](https://spcldace.readthedocs.io/en/latest/sdfg/ir.html#library-nodes) that specifies that an array should be filled with a certain value. This is also a performant feature because it can be specialized. Examples:
* Filling an array with a zero value (or any integer) can be lowered to a `memset` call, or `{cuda,hip}Memset` for GPUs
* Tensor/Matrix Core memory on GPUs can use `wmma::fill_fragment`

The library node should be implemented with one output leading to the data container to be filled, and an optional input connector called `value` which can specify a runtime value to fill. In case the value is constant or symbolic, the input may exist as a property. This is similar to how `alpha`/`beta` values are treated in matrix multiplication library nodes.

The library node will live in the DaCe [Standard](https://github.com/spcl/dace/tree/master/dace/libraries/standard) library, similarly to other basic operations such as Reduce. To help with the implementation, refer to the [einsum](https://github.com/spcl/dace/blob/master/dace/libraries/blas/nodes/einsum.py) library node. To see how input/output connectors can be defined, refer to [TensorTranspose](https://github.com/spcl/dace/blob/master/dace/libraries/standard/nodes/ttranspose.py).

The implementation tasks are as follows:
1. Implement the `Fill` library node in the Standard library
2. Implement a native expansion that uses only SDFG components under the `'pure'` expansion
3. (optional) Implement fast specializations
4. Create Fill library nodes in the Python frontend instead of the manual implementation (replacing the implementation of [numpy.full](https://github.com/spcl/dace/blob/ee5a6dfe695f329c3882105b087f3563a0c80b81/dace/frontend/python/replacements.py#L304))

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.