torch_harmonics.distributed.unpad_and_unflatten_leading_dims#
- torch_harmonics.distributed.unpad_and_unflatten_leading_dims(
- tensor,
- lead_shape,
- lead_size,
- num_trailing_dims=2,
Inverse of
flatten_and_pad_leading_dims(): drop the padding rows and restore the leading dims.The trailing
num_trailing_dimsdims are taken fromtensoras-is, so this is valid even when the transform changed them (e.g.nlat, nlon->lmax, mmax).num_trailing_dimsmust match the value passed to the flatten call.Complex inputs (the forward SHTs call this on their spectral output) are processed as their real view: this is pure layout code touching only the leading dims, and a copy over a complex buffer cannot be codegen’d by inductor – triton has no complex type, so it fails with
KeyError: 'complex64'.view_as_realappends the re/im pair as a trailing dim, which is simply carried along; thecontiguous()right before theview_as_complexsupplies the unit last-dim stride the latter requires.