Skip to content

Update Tensors tutorial — use torch.accelerator for device-agnostic code #3876

@sekyondaMeta

Description

@sekyondaMeta

Description

The Tensors tutorial contains outdated patterns that should be modernized.

Changes needed

Suboptimal / Outdated Patterns

Issue Current Code Modern Alternative Notes
Only checking CUDA ignores other accelerators if torch.cuda.is_available(): tensor = tensor.to('cuda') device = torch.accelerator.current_accelerator().type if torch.accelerator.is_available() else 'cpu' Since PyTorch 2.4+, torch.accelerator provides a device-agnostic API covering CUDA, MPS, XPU, etc.

Files

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions