Fix generator expression error w/ list comprehension (#7)
* Fix incompatibility with older Python versions in expression flip function handler
This commit is contained in:
@@ -102,11 +102,11 @@ class FlipHandler(NormHandler):
|
||||
return torch.flip(tensor, (dim,))
|
||||
result = tensor.detach().clone()
|
||||
pivot = tensor.shape[dim] // 2
|
||||
out_slice = (
|
||||
out_slice = tuple(
|
||||
np.s_[:] if d != dim else np.s_[pivot:] for d in range(tensor.ndim)
|
||||
)
|
||||
in_slice = (np.s_[:] if d != dim else np.s_[:pivot] for d in range(tensor.ndim))
|
||||
result[*out_slice] = torch.flip(tensor[*in_slice], dims=(dim,))
|
||||
in_slice = tuple(np.s_[:] if d != dim else np.s_[:pivot] for d in range(tensor.ndim))
|
||||
result[out_slice] = torch.flip(tensor[in_slice], dims=(dim,))
|
||||
return result
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user