Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions test/test_tv_tensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def test_force_subclass_with_metadata(return_type):
if return_type == "TVTensor":
assert bbox.format, bbox.canvas_size == (format, canvas_size)

if torch.cuda.is_available():
bbox = bbox.pin_memory()
if return_type == "TVTensor":
assert bbox.format, bbox.canvas_size == (format, canvas_size)

assert not bbox.requires_grad
bbox.requires_grad_(True)
if return_type == "TVTensor":
Expand Down
8 changes: 7 additions & 1 deletion torchvision/tv_tensors/_torch_function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@ def _must_return_subclass():


# For those ops we always want to preserve the original subclass instead of returning a pure Tensor
_FORCE_TORCHFUNCTION_SUBCLASS = {torch.Tensor.clone, torch.Tensor.to, torch.Tensor.detach, torch.Tensor.requires_grad_}
_FORCE_TORCHFUNCTION_SUBCLASS = {
torch.Tensor.clone,
torch.Tensor.to,
torch.Tensor.detach,
torch.Tensor.requires_grad_,
torch.Tensor.pin_memory,
}
Loading