Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fill library node #1576

Open
tbennun opened this issue May 16, 2024 · 7 comments
Open

Fill library node #1576

tbennun opened this issue May 16, 2024 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers libraries Issues related to DaCe libraries/library nodes.

Comments

@tbennun
Copy link
Collaborator

tbennun commented May 16, 2024

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 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 library, similarly to other basic operations such as Reduce. To help with the implementation, refer to the einsum library node. To see how input/output connectors can be defined, refer to TensorTranspose.

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)
@tbennun tbennun added enhancement New feature or request good first issue Good for newcomers libraries Issues related to DaCe libraries/library nodes. labels May 16, 2024
@tbennun tbennun changed the title Fill data container library node Fill library node May 16, 2024
@sahaj1997
Copy link

Hey @tbennun
Is this issue still open and could I take this up ?
Looking at the file history of https://github.com/spcl/dace/tree/master/dace/libraries it looks like I can.

@tbennun
Copy link
Collaborator Author

tbennun commented Aug 1, 2024

@sahaj1997 Yes! This issue is open and you can take it up. I added some resources on the original post that may be useful.

@kuku929
Copy link

kuku929 commented Sep 16, 2024

hello, is this issue resolved? If not, I would like to take it up

@tbennun
Copy link
Collaborator Author

tbennun commented Sep 17, 2024

@kuku929 As long as this issue is open, it is not resolved. We are happy to take any contribution! Please see the above resources.

@kuku929
Copy link

kuku929 commented Sep 17, 2024

I went ahead wrote a basic implementation: https://pastebin.com/B20rvYiM
since I am new to the library, can you help me out with the questions I have put in the comments?

@tbennun
Copy link
Collaborator Author

tbennun commented Sep 18, 2024

Thanks, this looks like a great start! Please post any questions in the issue, as it may help others too. I think you can use that as a basis for a PR. Make one and refer to it here so that we can track it. You should add some tests as well.
Additionally, I would not use string-based APIs for ranges, you can just give the shape of the array in the map range as a dace.subsets.Range object. Look at Range.from_array for more information.

@kuku929
Copy link

kuku929 commented Sep 20, 2024

Hello, I have created a draft pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers libraries Issues related to DaCe libraries/library nodes.
Projects
None yet
Development

No branches or pull requests

3 participants