@@ -21,8 +21,6 @@ namespace paddle {
21
21
22
22
REGISTER_LAYER (cudnn_batch_norm, CudnnBatchNormLayer);
23
23
24
- const double CudnnBatchNormLayer::MIN_EPS = 1E-5 ;
25
-
26
24
bool CudnnBatchNormLayer::init (const LayerMap& layerMap,
27
25
const ParameterMap& parameterMap) {
28
26
/* Initialize the basic parent class */
@@ -61,14 +59,8 @@ void CudnnBatchNormLayer::forward(PassType passType) {
61
59
real* movingMean = movingMean_->getW ()->getData ();
62
60
real* movingVar = movingVar_->getW ()->getData ();
63
61
64
- /* *
65
- * If epsilon_ equals to 1e-5 and eps_ is assigned the value of
66
- * static_cast<double>(epsilon_), The CUDNN_STATUS_BAD_PARAM error
67
- * will occur due to eps_ value is less than
68
- * CUDNN_BN_MIN_EPSILON.
69
- * The following code is to ensure that the eps_ meets requirement.
70
- */
71
- eps_ = std::max (MIN_EPS, static_cast <double >(epsilon_));
62
+ // cuDNN does not allow an epsilon value less than CUDNN_BN_MIN_EPSILON.
63
+ eps_ = std::max (CUDNN_BN_MIN_EPSILON, static_cast <double >(epsilon_));
72
64
73
65
if (!useGlobalStats_) {
74
66
REGISTER_TIMER_INFO (" CudnnBatchFwTimer" , getName ().c_str ());
@@ -137,14 +129,8 @@ void CudnnBatchNormLayer::backward(const UpdateCallback& callback) {
137
129
real* savedMean = savedMean_->getData ();
138
130
real* savedInvVar = savedInvVar_->getData ();
139
131
140
- /* *
141
- * If epsilon_ equals to 1e-5 and eps_ is assigned the value of
142
- * static_cast<double>(epsilon_), The CUDNN_STATUS_BAD_PARAM error
143
- * will occur due to eps_ value is less than
144
- * CUDNN_BN_MIN_EPSILON.
145
- * The following code is to ensure that the eps_ meets requirement.
146
- */
147
- eps_ = std::max (MIN_EPS, static_cast <double >(epsilon_));
132
+ // cuDNN does not allow an epsilon value less than CUDNN_BN_MIN_EPSILON.
133
+ eps_ = std::max (CUDNN_BN_MIN_EPSILON, static_cast <double >(epsilon_));
148
134
149
135
auto create = [](MatrixPtr& m, size_t h, size_t w, real** p) {
150
136
Matrix::resizeOrCreate (m, h, w, false , true );
0 commit comments