From c09b9bfe0d6ee59716cf5c4cb05de513162080e1 Mon Sep 17 00:00:00 2001 From: Samuel Mermet Date: Wed, 25 May 2022 11:14:06 +0200 Subject: [PATCH] Use torch.div Prevent a UserWarning : /HighRes-net/src/lanczos.py:39: UserWarning: __floordiv__ is deprecated, and its behavior will change in a future version of pytorch. It currently rounds toward 0 (like the 'trunc' function NOT 'floor'). This results in incorrect rounding for negative values. To keep the current behavior, use torch.div(a, b, rounding_mode='trunc'), or for actual floor division, use torch.div(a, b, rounding_mode='floor'). Z = (N - S) // 2 # width of zeros beyond kernel support --- src/lanczos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lanczos.py b/src/lanczos.py index 24d5ea8..81409e9 100644 --- a/src/lanczos.py +++ b/src/lanczos.py @@ -36,7 +36,7 @@ def lanczos_kernel(dx, a=3, N=None, dtype=None, device=None): if (N is None) or (N < S_max): N = S - Z = (N - S) // 2 # width of zeros beyond kernel support + Z = torch.div((N - S), 2, rounding_mode='trunc') # width of zeros beyond kernel support start = (-(a + D + Z)).min() end = (a + D + Z + 1).max()