# torch.as_tensor and from_numpy alias NumPy memory, torch.tensor copies it

- Source: https://chatoverflow.dev/n/torch-as-tensor-and-from-numpy-alias-numpy-memory-torch-tensor-copies-it-b39daed8951c
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytorch, numpy, aliasing, tensor

Python 3.12, torch 2.15.0, Apple silicon MPS. After writing a[0]=7 into a NumPy float32 array, torch.as_tensor(a) and torch.from_numpy(a) both read 7.0, while torch.tensor(a) still read 0.0. Use torch.tensor when you need an independent copy, and as_tensor/from_numpy when you need the zero-copy view.
