(
a: TensorLikeType, indices_or_sections: DimsType
)
| 4059 | |
| 4060 | # CompositeImplicitAutograd - don't register decomp |
| 4061 | def hsplit( |
| 4062 | a: TensorLikeType, indices_or_sections: DimsType |
| 4063 | ) -> Tuple[TensorLikeType, ...]: |
| 4064 | torch._check( |
| 4065 | a.ndim >= 1, |
| 4066 | lambda: ( |
| 4067 | "torch.hsplit requires a tensor with at least 1 dimension, but got a tensor with " |
| 4068 | + str(a.ndim) |
| 4069 | + " dimensions!" |
| 4070 | ), |
| 4071 | ) |
| 4072 | dim = 0 if a.ndim == 1 else 1 |
| 4073 | if isinstance(indices_or_sections, IntLike): |
| 4074 | split_size = indices_or_sections |
| 4075 | torch._check( |
| 4076 | (split_size != 0 and a.shape[dim] % split_size == 0), |
| 4077 | lambda: ( |
| 4078 | "torch.hsplit attempted to split along dimension " |
| 4079 | + str(dim) |
| 4080 | + ", but the size of the dimension " |
| 4081 | + str(a.shape[dim]) |
| 4082 | + " is not divisible by the split_size " |
| 4083 | + str(split_size) |
| 4084 | + "!" |
| 4085 | ), |
| 4086 | ) |
| 4087 | return tensor_split(a, split_size, dim) |
| 4088 | |
| 4089 | torch._check_type( |
| 4090 | isinstance(indices_or_sections, (list, tuple)), |
| 4091 | lambda: ( |
| 4092 | "hsplit(): received an invalid combination of arguments. " |
| 4093 | "Expected indices_or_sections to be of type int, list of ints or tuple of ints " |
| 4094 | f"but got type {type(indices_or_sections)}" |
| 4095 | ), |
| 4096 | ) |
| 4097 | |
| 4098 | split_sizes = indices_or_sections |
| 4099 | return tensor_split(a, split_sizes, dim) |
| 4100 | |
| 4101 | |
| 4102 | # CompositeImplicitAutograd - don't register decomp |
nothing calls this directly
no test coverage detected
searching dependent graphs…