open3d.ml.tf.ops.invert_neighbors_list

open3d.ml.tf.ops.invert_neighbors_list(num_points, inp_neighbors_index, inp_neighbors_row_splits, inp_neighbors_attributes, name=None)

Inverts a neighbors list made of neighbors_index and neighbors_row_splits.

This op inverts the neighbors list as returned from the neighbor search ops. The role of query points and input points is reversed in the returned list. The following example illustrates this:

import open3d.ml.tf as ml3d

# in this example we have 4 points and 3 query points with 3, 1, and 2 neighbors
# the mapping is 0->(0,1,2), 1->(2), 2->(1,3)
neighbors_index = [0, 1, 2, 2, 1, 3]
neighbors_row_splits = [0, 3, 4, 6]
# optional attributes for each pair
neighbors_attributes = [10, 20, 30, 40, 50, 60]

ans = ml3d.ops.invert_neighbors_list(4,
                                     neighbors_index,
                                     neighbors_row_splits,
                                     neighbors_attributes)
# returns ans.neighbors_index      = [0, 0, 2, 0, 1, 2]
#         ans.neighbors_row_splits = [0, 1, 3, 5, 6]
#         ans.neighbors_attributes = [10, 20, 50, 30, 40, 60]
# which is the mapping 0->(0), 1->(0,2), 2->(0,1), 3->(2)
# note that the order of the neighbors can be permuted

# or with pytorch
import torch
import open3d.ml.torch as ml3d

# in this example we have 4 points and 3 query points with 3, 1, and 2 neighbors
# the mapping is 0->(0,1,2), 1->(2), 2->(1,3)
neighbors_index = torch.IntTensor([0, 1, 2, 2, 1, 3])
neighbors_row_splits = torch.LongTensor([0, 3, 4, 6])
# optional attributes for each pair
neighbors_attributes = torch.Tensor([10, 20, 30, 40, 50, 60])

ans = ml3d.ops.invert_neighbors_list(4,
                                     neighbors_index,
                                     neighbors_row_splits,
                                     neighbors_attributes)
# returns ans.neighbors_index      = [0, 0, 2, 0, 1, 2]
#         ans.neighbors_row_splits = [0, 1, 3, 5, 6]
#         ans.neighbors_attributes = [10, 20, 50, 30, 40, 60]
# which is the mapping 0->(0), 1->(0,2), 2->(0,1), 3->(2)
# note that the order of the neighbors can be permuted
Parameters
  • num_points – A Tensor of type int64. Scalar integer with the number of points that have been tested in a neighbor search. This is the number of the points in the second point cloud (not the query point cloud) in a neighbor search. The size of the output neighbors_row_splits will be num_points +1.

  • inp_neighbors_index – A Tensor. Must be one of the following types: int32. The input neighbor indices stored linearly.

  • inp_neighbors_row_splits – A Tensor of type int64. The number of neighbors for the input queries as exclusive prefix sum. The prefix sum includes the total number as last element.

  • inp_neighbors_attributes – A Tensor. Must be one of the following types: int32, int64, float32, float64. Array that stores an attribute for each neighbor. The size of the first dim must match the first dim of inp_neighbors_index. To ignore attributes pass a 1D Tensor with zero size.

  • name – A name for the operation (optional).

Returns

A tuple of Tensor objects (neighbors_index, neighbors_row_splits, neighbors_attributes).

neighbors_index: A Tensor. Has the same type as inp_neighbors_index. The output neighbor indices stored

linearly.

neighbors_row_splits: A Tensor of type int64. Stores the number of neighbors for the new queries,

previously the input points, as exclusive prefix sum including the total number in the last element.

neighbors_attributes: A Tensor. Has the same type as inp_neighbors_attributes. Array that stores an attribute for each neighbor.

If the inp_neighbors_attributes Tensor is a zero length vector then the output will be a zero length vector as well.