From d135408b965da4d9c2d7ec0de37f526f9d401ce0 Mon Sep 17 00:00:00 2001 From: Eric Cosatto Date: Mon, 2 Oct 2017 15:36:29 -0400 Subject: [PATCH] fix condition logic for coef recalculation in SpatialSubtractiveNormalization (#1283) * replace lon glong types with size_t Work around bug in msvc compiler in win32 mode * fix condition logic for coef recalculation in SpatialSubtractiveNormalization Existing conditional expression always verified, resulting in overhead as coeffcients were recalculated every time. Fix and simplify expression by using chached input size. --- SpatialSubtractiveNormalization.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SpatialSubtractiveNormalization.lua b/SpatialSubtractiveNormalization.lua index e2da2c6a2..7fa440267 100644 --- a/SpatialSubtractiveNormalization.lua +++ b/SpatialSubtractiveNormalization.lua @@ -63,7 +63,8 @@ end function SpatialSubtractiveNormalization:updateOutput(input) -- compute side coefficients local dim = input:dim() - if input:dim()+1 ~= self.coef:dim() or (input:size(dim) ~= self.coef:size(dim)) or (input:size(dim-1) ~= self.coef:size(dim-1)) then + if not self._inpsz or not input:isSize(self._inpsz) then + self._inpsz = input:size() self.ones = self.ones or input.new() self._coef = self._coef or self.coef.new() if dim == 4 then