traveller59 / spconv

Spatial Sparse Convolution Library
Apache License 2.0
1.89k stars 366 forks source link

how to align the order of indices #713

Open repoww opened 4 months ago

repoww commented 4 months ago
pooling = spconv.SparseAvgPool3d(kernel_size=2, stride=2)
conv1= spconv.SparseConv3d(
        3,
        3,
        2,
        stride=2,
        padding=0,
        dilation=1,
        bias=False
    )
data = spconv.SparseConvTensor(
        features=features.cuda(),
        indices=batch_indices.cuda(),
        spatial_shape=batch_indices.max(0)[0][1:] + 1,
        batch_size=1
    )
coordinates = spconv.SparseConvTensor(
        features=raw_coordinates.cuda(),
        indices=batch_indices.cuda(),
        spatial_shape=batch_indices.max(0)[0][1:] + 1,
        batch_size=1
    )

coords = pooling(coordinates)
embeddings = conv1(data)

How can I align the indices of coords and embbeddings to be the same to use coords as input of positional encoding. The two inputs share the same indices, with conv(stride=2) and pooling(stride=2), the output indices should be the same?

Looks like the set of the conv output and pooling output indices are the same but in different orders.

Thanks

repoww commented 4 months ago

Probably, I should do pooling of raw_coordinates based on the indice_dict from embeddings and just replace the features of embeddings