Commit bbc25706 authored by rusty1s's avatar rusty1s
Browse files

added python impl

parent af7786d8
...@@ -5,17 +5,12 @@ from .utils import get_func ...@@ -5,17 +5,12 @@ from .utils import get_func
def grid_cluster(position, size, batch=None): def grid_cluster(position, size, batch=None):
# TODO: Check types and sizes # TODO: Check types and sizes
print(batch.type())
print(position.type())
if batch is not None: if batch is not None:
batch = batch.type_as(position) batch = batch.type_as(position)
position = torch.cat([position, batch], dim=position.dim() - 1) position = torch.cat([position, batch], dim=position.dim() - 1)
size = torch.cat([size, size.new(1).fill_(1)], dim=0) size = torch.cat([size, size.new(1).fill_(1)], dim=0)
print(position)
# TODO: BATCH
# print(position[0])
# print(position[1])
dim = position.dim() dim = position.dim()
# Allow one-dimensional positions. # Allow one-dimensional positions.
...@@ -32,6 +27,7 @@ def grid_cluster(position, size, batch=None): ...@@ -32,6 +27,7 @@ def grid_cluster(position, size, batch=None):
while max.dim() > 1: while max.dim() > 1:
max = max.max(dim=0)[0] max = max.max(dim=0)[0]
c_max = torch.ceil(max / size.type_as(max)).long() c_max = torch.ceil(max / size.type_as(max)).long()
c_max = torch.clamp(c_max, min=1)
C = c_max.prod() C = c_max.prod()
# Generate cluster tensor. # Generate cluster tensor.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment