[WIP] Improve reducer API for memory allocation & compute#9290
Draft
acosmicflamingo wants to merge 4 commits into
Draft
[WIP] Improve reducer API for memory allocation & compute#9290acosmicflamingo wants to merge 4 commits into
acosmicflamingo wants to merge 4 commits into
Conversation
Contributor
3d56a30 to
b17dadc
Compare
Contributor
Author
|
@shwina I imagine that we want to avoid something like this, correct? diff a/python/cuda_cccl/cuda/compute/algorithms/_reduce.py
b/python/cuda_cccl/cuda/compute/algorithms/_reduce.py
@@ -35,6 +35,8 @@ from ..typing import (
class _Reduce:
__slots__ = [
+ "d_in",
+ "d_out",
"d_in_cccl",
"d_out_cccl",
"h_init_cccl",
@@ -52,6 +54,8 @@ class _Reduce:
h_init: np.ndarray | GpuStruct,
determinism: Determinism,
):
+ self.d_in = d_in
+ self.d_out = d_out
self.d_in_cccl = cccl.to_cccl_input_iter(d_in)
self.d_out_cccl = cccl.to_cccl_output_iter(d_out)
self.h_init_cccl = cccl.to_cccl_value(h_init)
@@ -152,8 +156,8 @@ class _Reduce:
h_init: np.ndarray | GpuStruct,
stream=None,
):
- set_cccl_iterator_state(self.d_in_cccl, d_in)
- set_cccl_iterator_state(self.d_out_cccl, d_out)
+ set_cccl_iterator_state(self.d_in_cccl, self.d_in)
+ set_cccl_iterator_state(self.d_out_cccl, self.d_out)
# Update op state for stateful ops
op_adapter = make_op_adapter(op)On the surface, it would pave the way for implementing the API we seek. However, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Resolves #5638
Add 'get_temp_storage_bytes' and 'compute' functions to _Reduce class to improve API usability (as suggested by @kkraus14 and @shwina).
Checklist