@@ -116,7 +116,9 @@ def initialize_coordinates(self, coordinates, features, coordinate_map_key):
116116 spmm = MinkowskiSPMMFunction ()
117117 N = len (features )
118118 cols = torch .arange (
119- N , dtype = self .inverse_mapping .dtype , device = self .inverse_mapping .device ,
119+ N ,
120+ dtype = self .inverse_mapping .dtype ,
121+ device = self .inverse_mapping .device ,
120122 )
121123 vals = torch .ones (N , dtype = features .dtype , device = features .device )
122124 size = torch .Size ([len (self .unique_index ), len (self .inverse_mapping )])
@@ -126,7 +128,11 @@ def initialize_coordinates(self, coordinates, features, coordinate_map_key):
126128 == SparseTensorQuantizationMode .UNWEIGHTED_AVERAGE
127129 ):
128130 nums = spmm .apply (
129- self .inverse_mapping , cols , vals , size , vals .reshape (N , 1 ),
131+ self .inverse_mapping ,
132+ cols ,
133+ vals ,
134+ size ,
135+ vals .reshape (N , 1 ),
130136 )
131137 features /= nums
132138 elif self .quantization_mode == SparseTensorQuantizationMode .RANDOM_SUBSAMPLE :
@@ -139,8 +145,7 @@ def initialize_coordinates(self, coordinates, features, coordinate_map_key):
139145
140146 @property
141147 def C (self ):
142- r"""The alias of :attr:`coords`.
143- """
148+ r"""The alias of :attr:`coords`."""
144149 return self .coordinates
145150
146151 @property
@@ -154,10 +159,17 @@ def coordinates(self):
154159 internally treated as an additional spatial dimension to disassociate
155160 different instances in a batch.
156161 """
157- if not hasattr (self , ' _CC' ) or self ._CC is None :
162+ if not hasattr (self , " _CC" ) or self ._CC is None :
158163 self ._CC = self ._get_coordinate_field ()
159164 return self ._CC
160165
166+ @property
167+ def _batchwise_row_indices (self ):
168+ if self ._batch_rows is None :
169+ batch_inds = torch .unique (self ._CC [:, 0 ])
170+ self ._batch_rows = [self ._CC [:, 0 ] == b for b in batch_inds ]
171+ return self ._batch_rows
172+
161173 def _get_coordinate_field (self ):
162174 return self ._manager .get_coordinate_field (self .coordinate_field_map_key )
163175
@@ -167,7 +179,9 @@ def sparse(self):
167179 N = len (self ._F )
168180 assert N == len (self .inverse_mapping ), "invalid inverse mapping"
169181 cols = torch .arange (
170- N , dtype = self .inverse_mapping .dtype , device = self .inverse_mapping .device ,
182+ N ,
183+ dtype = self .inverse_mapping .dtype ,
184+ device = self .inverse_mapping .device ,
171185 )
172186 vals = torch .ones (N , dtype = self ._F .dtype , device = self ._F .device )
173187 size = torch .Size (
@@ -176,7 +190,13 @@ def sparse(self):
176190 features = spmm .apply (self .inverse_mapping , cols , vals , size , self ._F )
177191 # int_inverse_mapping = self.inverse_mapping.int()
178192 if self .quantization_mode == SparseTensorQuantizationMode .UNWEIGHTED_AVERAGE :
179- nums = spmm .apply (self .inverse_mapping , cols , vals , size , vals .reshape (N , 1 ),)
193+ nums = spmm .apply (
194+ self .inverse_mapping ,
195+ cols ,
196+ vals ,
197+ size ,
198+ vals .reshape (N , 1 ),
199+ )
180200 features /= nums
181201
182202 return SparseTensor (
0 commit comments