17
17
#include < cfloat>
18
18
19
19
#include " caffe2/core/context_gpu.h"
20
- #include " sigmoid_focal_loss_op.h"
20
+ #include " modules/detectron/ sigmoid_focal_loss_op.h"
21
21
22
22
namespace caffe2 {
23
23
@@ -45,15 +45,15 @@ __global__ void SigmoidFocalLossKernel(
45
45
float c1 = (t == (d + 1 ));
46
46
float c2 = (t != -1 & t != (d + 1 ));
47
47
48
- float Np = max (weight_pos[0 ], 1.0 );
48
+ float Np = c10::cuda::compat:: max (weight_pos[0 ], static_cast < float >( 1.0 ) );
49
49
float zn = (1.0 - alpha) / Np;
50
50
float zp = alpha / Np;
51
51
52
52
// p = 1. / 1. + expf(-x)
53
53
float p = 1 . / (1 . + expf (-logits[i]));
54
54
55
55
// (1 - p)**gamma * log(p) where
56
- float term1 = powf ((1 . - p), gamma ) * logf (max (p, FLT_MIN));
56
+ float term1 = powf ((1 . - p), gamma ) * logf (c10::cuda::compat:: max (p, FLT_MIN));
57
57
// p**gamma * log(1 - p)
58
58
float term2 =
59
59
powf (p, gamma ) *
@@ -82,7 +82,7 @@ __global__ void SigmoidFocalLossGradientKernel(
82
82
int a = c / num_classes; // current anchor
83
83
int d = c % num_classes; // current class
84
84
85
- float Np = max (weight_pos[0 ], 1.0 );
85
+ float Np = c10::cuda::compat:: max (weight_pos[0 ], static_cast < float >( 1.0 ) );
86
86
float zn = (1.0 - alpha) / Np;
87
87
float zp = alpha / Np;
88
88
int t = targets[n * (H * W * A) + a * (H * W) + y * W + x];
@@ -94,7 +94,7 @@ __global__ void SigmoidFocalLossGradientKernel(
94
94
// (1-p)**g * (1 - p - g*p*log(p))
95
95
float term1 =
96
96
powf ((1 . - p), gamma ) *
97
- (1 . - p - (p * gamma * logf (max (p, FLT_MIN))));
97
+ (1 . - p - (p * gamma * logf (c10::cuda::compat:: max (p, FLT_MIN))));
98
98
// (p**g) * (g*(1-p)*log(1-p) - p)
99
99
float term2 =
100
100
powf (p, gamma ) *
0 commit comments