Skip to content

Commit

Permalink
Allow None in up-/downsample2x()
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Holl committed Oct 25, 2024
1 parent e84e192 commit d80a7f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions phiml/math/_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,8 @@ def downsample2x(grid: Tensor,
half-size grid
"""
if grid is None:
return None
dims = grid.shape.only(dims).names
odd_dimensions = [dim for dim in dims if grid.shape.get_size(dim) % 2 != 0]
grid = math.pad(grid, {dim: (0, 1) for dim in odd_dimensions}, padding)
Expand Down Expand Up @@ -1021,6 +1023,8 @@ def upsample2x(grid: Tensor,
double-size grid
"""
if grid is None:
return None
for dim in grid.shape.only(dims):
left, center, right = shift(grid, (-1, 0, 1), dim.names, padding, None, padding_kwargs=padding_kwargs)
interp_left = 0.25 * left + 0.75 * center
Expand Down

0 comments on commit d80a7f7

Please sign in to comment.