rand module

Hash

pt_hash_uint(x[, normalize])

1D XQO-style hash for PyTorch.

pt_hash2_uint(x, y[, normalize])

2D XQO-style hash for PyTorch.

pt_hash2_uv(uv[, seed, tile_size])

2D normalized UV hash for PyTorch.

pt_hash2_xy(xy[, seed, tile_size])

2D denormalized XY hash for PyTorch.

np_hash_uint(x[, normalize])

1D XQO-style hash for NumPy.

np_hash2_uint(x, y[, normalize])

2D XQO-style hash for NumPy.

Scramble

pt_noise2(p)

2D value noise scramble.

pt_noise3(p)

3D value noise scramble.

tinytex.rand.pt_hash_uint(x, normalize=False)[source]

1D XQO-style hash for PyTorch.

Parameters:
  • x (torch.Tensor) – Input int tensor.

  • normalize (bool) – If True, returns float32 values in [0, 1].

Returns:

Hashed tensor (uint32 or float32).

Return type:

torch.Tensor

tinytex.rand.pt_hash2_uint(x, y, normalize=False)[source]

2D XQO-style hash for PyTorch.

Parameters:
  • x (torch.Tensor) – X coordinates (int tensor).

  • y (torch.Tensor) – Y coordinates (int tensor).

  • normalize (bool) – If True, returns float32 in [0, 1].

Returns:

Hashed values (uint32 or float32).

Return type:

torch.Tensor

tinytex.rand.pt_hash2_uv(uv, seed=0, tile_size=1023)[source]

2D normalized UV hash for PyTorch. Expects normalized coordinates. Produces uniform pseudo-random values.

Parameters:
  • uv (torch.Tensor) – Tensor of shape [2, H, W] with values in [0, 1].

  • seed (int) – Optional seed for scrambling.

  • tile_size (int) – Maximum tile size (default: 1023).

Returns:

Tensor of shape [H, W] with float32 values in [0, 1].

Return type:

torch.Tensor

tinytex.rand.pt_hash2_xy(xy, seed=0, tile_size=1023)[source]

2D denormalized XY hash for PyTorch. Expects denormalized integer coordinates. Produces uniform pseudo-random values.

Parameters:
  • xy (torch.Tensor) – Tensor of shape [2, H, W] with integer coordinates.

  • seed (int) – Optional seed for scrambling.

  • tile_size (int) – Maximum tile size (default: 1023).

Returns:

Tensor of shape [H, W] with float32 values in [0, 1].

Return type:

torch.Tensor

tinytex.rand.np_hash_uint(x, normalize=False)[source]

1D XQO-style hash for NumPy.

Parameters:
  • x (ndarray) – Input array (uint32-compatible).

  • normalize (bool) – If True, returns float32 values in [0, 1].

Returns:

Hashed values (uint32 or float32).

Return type:

ndarray

tinytex.rand.np_hash2_uint(x, y, normalize=False)[source]

2D XQO-style hash for NumPy.

Parameters:
  • x (ndarray) – X array (uint32-compatible).

  • y (ndarray) – Y array (uint32-compatible).

  • normalize – If True, returns float32 values in [0, 1].

Returns:

Hashed values (uint32 or float32).

Return type:

ndarray

tinytex.rand.pt_noise2(p)[source]

2D value noise scramble.

Parameters:

p (torch.Tensor) – Input tensor of shape [2, H, W].

Returns:

Scrambled tensor of shape [2, H, W], float32 in [0, 1].

Return type:

torch.Tensor

tinytex.rand.pt_noise3(p)[source]

3D value noise scramble.

Parameters:

p (torch.Tensor) – Input tensor of shape [3, H, W].

Returns:

Scrambled tensor of shape [3, H, W], float32 in [0, 1].

Return type:

torch.Tensor