def forward(self, input: SparseTensor, coords: Union[torch.IntTensor, CoordsKey, SparseTensor] = None): r""" :attr:`input` (`MinkowskiEngine.SparseTensor`): Input sparse tensor to apply a convolution on. :attr:`coords` ((`torch.IntTensor`, `MinkowskiEngine.CoordsKey`, `MinkowskiEngine.SparseTensor`), optional): If provided, generate results on the provided coordinates. None by default. """ assert isinstance(input, SparseTensor) assert input.D == self.dimension # Create a region_offset self.region_type_, self.region_offset_, _ = \ self.kernel_generator.get_kernel(input.tensor_stride, self.is_transpose) # Get a new coords key or extract one from the coords out_coords_key = _get_coords_key(input, coords) output = self.pooling.apply(input.F, input.tensor_stride, self.stride, self.kernel_size, self.dilation, self.region_type_, self.region_offset_, self.average, input.coords_key, out_coords_key, input.coords_man) return SparseTensor(output, coords_key=out_coords_key, coords_manager=input.coords_man)
def forward(self, input: SparseTensor, coords: Union[torch.IntTensor, CoordsKey, SparseTensor] = None): r""" :attr:`input` (`MinkowskiEngine.SparseTensor`): Input sparse tensor to apply a convolution on. :attr:`coords` ((`torch.IntTensor`, `MinkowskiEngine.CoordsKey`, `MinkowskiEngine.SparseTensor`), optional): If provided, generate results on the provided coordinates. None by default. """ assert isinstance(input, SparseTensor) assert input.D == self.dimension # Create a region_offset self.region_type_, self.region_offset_, _ = \ self.kernel_generator.get_kernel(input.tensor_stride, self.is_transpose) if self.use_mm and coords is None: # If the kernel_size == 1, the convolution is simply a matrix # multiplication outfeat = input.F.mm(self.kernel) out_coords_key = input.coords_key else: if self.is_transpose: conv = MinkowskiConvolutionTransposeFunction() else: conv = MinkowskiConvolutionFunction() # Get a new coords key or extract one from the coords out_coords_key = _get_coords_key(input, coords) outfeat = conv.apply(input.F, self.kernel, input.tensor_stride, self.stride, self.kernel_size, self.dilation, self.region_type_, self.region_offset_, input.coords_key, out_coords_key, input.coords_man) if self.has_bias: outfeat += self.bias return SparseTensor(outfeat, coords_key=out_coords_key, coords_manager=input.coords_man)