8000 Add pinned memory support to sparse COO/CSR/CSC/BSR/BSC tensors by pearu · Pull Request #129645 · pytorch/pytorch · GitHub
[go: up one dir, main page]

Skip to content

Add pinned memory support to sparse COO/CSR/CSC/BSR/BSC tensors #129645

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

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update on "Add pinned memory support to sparse COO/CSR/CSC/BSR/BSC te…
…nsors"

As in the title:

To register indices/values of a sparse XYZ tensor with CUDA, the following methods are supported
- `sparse_xyz_tensor(indices, values, pin_memory=True)`
- `sparse_xyz_tensor(indices, values).pin_memory()`
- `sparse_xyz_tensor(indices.pin_memory(), values.pin_memory())`

Fixes #115330




[ghstack-poisoned]
  • Loading branch information
pearu committed Jun 28, 2024
commit 5f091ba2d300034fa899a809dead64d12153ee43
2 changes: 1 addition & 1 deletion aten/src/ATen/native/native_functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4561,7 +4561,7 @@
MPS: _pin_memory_mps
NestedTensorCUDA, NestedTensorCPU: _pin_memory_nested
SparseCUDA: _pin_memory_sparse_coo
SparseCsrCUDA: _pin_memory_sparse_compressed
SparseCsrCUDA, SparseCsrCPU: _pin_memory_sparse_compressed
autogen: _pin_memory.out

- func: pinverse(Tensor self, float rcond=1e-15) -> Tensor
Expand Down
8 changes: 4 additions & 4 deletions test/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5341,10 +5341,11 @@ def test_invalid_blocksize(self):
torch.randn(1).to_sparse(blocksize=torch.Size((1, 1, 1)))

@onlyCPU
@all_sparse_layouts('layout', include_strided=not False)
@all_sparse_layouts('layout', include_strided=True)
def test_constructor_pin_memory(self, device, layout):
"""Tests sparse_xyz_tensor(indices, values, pin_memory=True)
"""
self.assertEqual(device, "cpu")
for t in self.generate_simple_inputs(
layout, device=device, dtype=torch.float64,
enable_zero_sized=False, # pinning zero-sized tensors is a no-op
Expand All @@ -5369,7 +5370,7 @@ def test_constructor_pin_memory(self, device, layout):
self.assertTrue(t.is_pinned())

@onlyCPU
@all_sparse_layouts('layout', include_strided=not False)
@all_sparse_layouts('layout', include_strided=True)
def test_method_pin_memory(self, device, layout):
"""Tests sparse_xyz_tensor(indices, values, pin_memory=False).pin_memory(device)
"""
Expand Down Expand Up @@ -5401,8 +5402,7 @@ def test_method_pin_memory(self, device, layout):
self.assertTrue(t.is_pinned(pin_memory_device))

@onlyCPU
# @unittest.skipIf(not TEST_MULTIGPU, "multi-GPU not supported")
@all_sparse_layouts('layout', include_strided=not False)
@all_sparse_layouts('layout', include_strided=True)
def test_constructor_pinned_memory(self, device, layout):
"""Tests sparse_xyz_tensor(indices.pin_memory(device), values.pin_memory(device))
"""
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0