Remove use of broken THInf macro, which caused UB
* [VolmetricMaxPooling] Remove use of broken THInf macro, which caused UB
* [SpatialFractionalMaxPooling] Remove use of broken THInf macro, which caused UB
diff --git a/SpatialFractionalMaxPooling.cu b/SpatialFractionalMaxPooling.cu
index d1a9c92..dc92d70 100644
--- a/SpatialFractionalMaxPooling.cu
+++ b/SpatialFractionalMaxPooling.cu
@@ -4,6 +4,8 @@
#include "THCDeviceTensorUtils.cuh"
#include "THCDeviceUtils.cuh"
+#include <cfloat>
+
__device__ inline float getInterval(float sample,
int index,
int inputSize,
@@ -41,7 +43,7 @@
int poolH = getInterval(samples[batch][plane][1], outputH,
input.getSize(2), output.getSize(2), poolSizeH);
- float maxVal = -THInf;
+ float maxVal = -FLT_MAX;
int maxIndex = -1;
for (int h = poolH; h < poolH + poolSizeH; ++h) {
@@ -62,7 +64,7 @@
}
}
- assert(maxVal != -THInf);
+ assert(maxVal != -FLT_MAX);
assert(maxIndex != -1);
// +1 for Lua index
diff --git a/VolumetricMaxPooling.cu b/VolumetricMaxPooling.cu
index c3aa098..f173923 100644
--- a/VolumetricMaxPooling.cu
+++ b/VolumetricMaxPooling.cu
@@ -4,6 +4,8 @@
#include "THCDeviceTensorUtils.cuh"
#include "THCDeviceUtils.cuh"
+#include <cfloat>
+
__global__ void cuda_VolumetricMaxPooling_updateOutput(
THCDeviceTensor<float, 4> input,
THCDeviceTensor<float, 4> indices,
@@ -27,7 +29,7 @@
int maxRow = 0;
int maxFrame = 0;
- float max = -THInf;
+ float max = -FLT_MAX;
for (int frame = 0; frame < kT; ++frame)
{
@@ -89,7 +91,7 @@
int maxRow = 0;
int maxFrame;
- float max = -THInf;
+ float max = -FLT_MAX;
for (int frame = 0; frame < kT; ++frame)
{