MCPcopy Create free account
hub / github.com/NVIDIA/MinkowskiEngine / _binary_functor

Method _binary_functor

MinkowskiEngine/MinkowskiTensor.py:511–546  ·  view source on GitHub ↗
(self, other, binary_fn)

Source from the content-addressed store, hash-verified

509 return self
510
511 def _binary_functor(self, other, binary_fn):
512 assert isinstance(other, (self.__class__, torch.Tensor))
513 if isinstance(other, self.__class__):
514 assert self._manager == other._manager, COORDINATE_MANAGER_DIFFERENT_ERROR
515
516 if self.coordinate_map_key == other.coordinate_map_key:
517 return self.__class__(
518 binary_fn(self._F, other.F),
519 coordinate_map_key=self.coordinate_map_key,
520 coordinate_manager=self._manager,
521 )
522 else:
523 # Generate union maps
524 out_key = CoordinateMapKey(
525 self.coordinate_map_key.get_coordinate_size()
526 )
527 union_maps = self.coordinate_manager.union_map(
528 [self.coordinate_map_key, other.coordinate_map_key], out_key
529 )
530 N_out = self.coordinate_manager.size(out_key)
531 out_F = torch.zeros(
532 (N_out, self._F.size(1)), dtype=self.dtype, device=self.device
533 )
534 out_F[union_maps[0][1]] = self._F[union_maps[0][0]]
535 out_F[union_maps[1][1]] = binary_fn(
536 out_F[union_maps[1][1]], other._F[union_maps[1][0]]
537 )
538 return self.__class__(
539 out_F, coordinate_map_key=out_key, coordinate_manager=self._manager
540 )
541 else: # when it is a torch.Tensor
542 return self.__class__(
543 binary_fn(self._F, other),
544 coordinate_map_key=self.coordinate_map_key,
545 coordinate_manager=self._manager,
546 )
547
548 def __add__(self, other):
549 r"""

Callers 4

__add__Method · 0.95
__sub__Method · 0.95
__mul__Method · 0.95
__truediv__Method · 0.95

Calls 4

CoordinateMapKeyClass · 0.85
get_coordinate_sizeMethod · 0.80
union_mapMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected