PyTorch torch.hash_tensor Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.hash_tensorIt is a function in PyTorch used for tensor hashing. Returns the hash value of the tensor.

Function Definition

torch.hash_tensor(tensor)

Usage Example

Example

import torch

# Create tensor
x = torch.tensor([1, 2, 3, 4, 5])
y = torch.tensor([1, 2, 3, 4, 5])

# Get hash value
hash_x = torch.hash_tensor(x)
hash_y = torch.hash_tensor(y)

print(f"Hash of x: {hash_x}")
print(f"Hash of y: {hash_y}")
print(f"Hashes equal: {hash_x == hash_y}")

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions