latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.hash_tensor
- tensorplay.functional.hash_tensor(input, *, mode=0) Tensor[source]
Returns a hash of all elements in the
inputtensor.Currently only mode=0 (reduction via xor) is supported. The output will always be of type
tensorplay.uint64. The elements ofinputare upcasted to their 64 bit float / integer equivalent and bitcasted totensorplay.uint64before reduction via xor.- Parameters:
input (Tensor) – the input tensor.
- Keyword Arguments:
mode (int) – The hash to use. Default: 0 (xor_reduction)
Example:
>>> a = tensorplay.randn(1, 3) >>> a tensor([[ 1.1918, -1.1813, 0.3373]]) >>> tensorplay.hash_tensor(a) tensor(13822780554648485888, dtype=tensorplay.uint64)Returns the hash of each row of the
inputtensor in the given dimensiondimgiven by mode. Ifdimis a list of dimensions, reduce over all of them.If
keepdimisTrue, the output tensor is of the same size asinputexcept in the dimension(s)dimwhere it is of size 1. Otherwise,dimis squeezed (seetensorplay.squeeze()), resulting in the output tensor having 1 (orlen(dim)) fewer dimension(s).- Parameters:
- Keyword Arguments:
mode (int) – The hash to use. Default: 0 (xor_reduction)
Example:
>>> a = tensorplay.randn(2, 4) >>> a tensor([[ 0.1317, -0.5554, -1.4724, -1.1391], [ 0.0778, -0.6070, 0.6375, 0.1798]]) >>> tensorplay.hash_tensor(a, 1) tensor([9233691267014066176, 9255993250844508160], dtype=tensorplay.uint64)
Help improve this page
Found an error, an unclear step, or a missing example?

