Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Lettensor_a.new_tensor() be ontensor_a.device by default#144958

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes from1 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
PrevPrevious commit
NextNext commit
add test
  • Loading branch information
@oraluben
oraluben committedJan 16, 2025
commitbfdaeabf87a38d0b6948cd828f88a17963ca33ed
17 changes: 17 additions & 0 deletionstest/test_tensor_creation_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2758,6 +2758,23 @@ def test_tensor_ctor_device_inference(self, device):
sparse_size, dtype=torch.float64)
self.assertEqual(sparse_with_dtype.device, torch.device('cpu'))

@onlyCUDA
@onlyNativeDeviceTypes
def test_new_tensor_device(self, device):
torch_device = torch.device(device)
cpu_device = torch.device('cpu')
tensor = torch.tensor((1, 2, 3), device=device)

# need more than one device_type to test this
assert self.device_type == 'cuda'

with warnings.catch_warnings():
warnings.simplefilter("ignore")

self.assertEqual(tensor.new_tensor(tensor.cpu()).device, torch_device)
self.assertEqual(tensor.cpu().new_tensor(tensor).device, cpu_device)
self.assertEqual(tensor.new_tensor(tensor, device=cpu_device).device, cpu_device)

def _test_signal_window_functions(self, name, dtype, device, **kwargs):
import scipy.signal as signal

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp