r"""Returns the coordinates map key.
(
input: SparseTensor,
coordinates: torch.Tensor = None,
tensor_stride: StrideType = 1,
expand_coordinates: bool = False,
)
| 738 | |
| 739 | |
| 740 | def _get_coordinate_map_key( |
| 741 | input: SparseTensor, |
| 742 | coordinates: torch.Tensor = None, |
| 743 | tensor_stride: StrideType = 1, |
| 744 | expand_coordinates: bool = False, |
| 745 | ): |
| 746 | r"""Returns the coordinates map key.""" |
| 747 | if coordinates is not None and not expand_coordinates: |
| 748 | assert isinstance(coordinates, (CoordinateMapKey, torch.Tensor, SparseTensor)) |
| 749 | if isinstance(coordinates, torch.Tensor): |
| 750 | assert coordinates.ndim == 2 |
| 751 | coordinate_map_key = CoordinateMapKey( |
| 752 | convert_to_int_list(tensor_stride, coordinates.size(1) - 1), "" |
| 753 | ) |
| 754 | |
| 755 | ( |
| 756 | coordinate_map_key, |
| 757 | (unique_index, inverse_mapping), |
| 758 | ) = input._manager.insert_and_map( |
| 759 | coordinates, *coordinate_map_key.get_key() |
| 760 | ) |
| 761 | elif isinstance(coordinates, SparseTensor): |
| 762 | coordinate_map_key = coordinates.coordinate_map_key |
| 763 | else: # CoordinateMapKey type due to the previous assertion |
| 764 | coordinate_map_key = coordinates |
| 765 | else: # coordinates is None |
| 766 | coordinate_map_key = CoordinateMapKey( |
| 767 | input.coordinate_map_key.get_coordinate_size() |
| 768 | ) |
| 769 | return coordinate_map_key |
no test coverage detected