From e2f6f80df2571ef8239fc500105e107008f5bda2 Mon Sep 17 00:00:00 2001 From: Ken Simpson Date: Sat, 4 Oct 2025 16:48:19 -0700 Subject: [PATCH] Fix Worley grid broadcasting for rectangular inputs --- __init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/__init__.py b/__init__.py index 8332517..9cb391c 100644 --- a/__init__.py +++ b/__init__.py @@ -327,13 +327,12 @@ def _worley_noise(size, seed, feature_points, metric, jitter, device): ys = torch.linspace(0.0, 1.0, steps=height, device=device, dtype=dtype) xs = torch.linspace(0.0, 1.0, steps=width, device=device, dtype=dtype) - grid_y = ys.view(height, 1, 1) - grid_x = xs.view(1, width, 1) + grid_y = ys.view(height, 1).expand(height, width) + grid_x = xs.view(1, width).expand(height, width) - diff_y = grid_y - points[:, 1] - diff_x = grid_x - points[:, 0] - - diff = torch.stack((diff_x, diff_y), dim=-1) + grid = torch.stack((grid_x, grid_y), dim=-1) + point_offsets = points.view(1, 1, feature_points, 2) + diff = grid.unsqueeze(2) - point_offsets if metric == "manhattan": distances = diff.abs().sum(dim=-1)