update tensors.py

This commit is contained in:
Ayo Ayco 2025-09-02 22:51:50 +02:00
parent 32fec1e081
commit adf6365438

View file

@ -34,9 +34,9 @@ print(f"Zeros: \n {zeros_tensor} \n")
tensor_attr = torch.rand(3,4).to('xpu')
# print(f"Shape: {tensor_attr.shape}")
# print(f"Datatype: {tensor_attr.dtype}")
# print(f"Device: {tensor_attr.device}")
print(f"Shape: {tensor_attr.shape}")
print(f"Datatype: {tensor_attr.dtype}")
print(f"Device: {tensor_attr.device}")
# indexing & slicing
@ -60,7 +60,7 @@ y3 = torch.rand_like(y1) # create a new tensor with same shape as y1
torch.matmul(tensor, tensor.T, out=y3)
# comput the element-wise product (z1, z2, z3 will have same values)
# compute the element-wise product (z1, z2, z3 will have same values)
z1 = tensor * tensor
z2 = tensor.mul(tensor)