@@ -24,9 +24,6 @@ limitations under the License. */
24
24
#include " paddle/fluid/platform/profiler.h"
25
25
26
26
DECLARE_bool (benchmark);
27
- DEFINE_bool (check_nan_inf, false ,
28
- " Checking whether operator produce NAN/INF or not. It will be "
29
- " extremely slow so please use this flag wisely." );
30
27
31
28
namespace paddle {
32
29
namespace framework {
@@ -78,21 +75,6 @@ void InitializeVariable(Variable* var, proto::VarType::Type var_type) {
78
75
}
79
76
}
80
77
81
- static void CheckTensorNANOrInf (const std::string& name,
82
- const framework::Tensor& tensor) {
83
- if (tensor.memory_size () == 0 ) {
84
- return ;
85
- }
86
- if (tensor.type ().hash_code () != typeid (float ).hash_code () && // NOLINT
87
- tensor.type ().hash_code () != typeid (double ).hash_code ()) { // NOLINT
88
- return ;
89
- }
90
- PADDLE_ENFORCE (!framework::TensorContainsInf (tensor),
91
- " Tensor %s contains Inf" , name);
92
- PADDLE_ENFORCE (!framework::TensorContainsNAN (tensor),
93
- " Tensor %s contains NAN" , name);
94
- }
95
-
96
78
void Executor::CreateVariables (const ProgramDesc& pdesc, Scope* scope,
97
79
int block_id) {
98
80
auto & global_block = pdesc.Block (block_id);
@@ -340,15 +322,6 @@ void Executor::RunPreparedContext(ExecutorPrepareContext* ctx, Scope* scope,
340
322
VLOG (2 ) << " Memory used after operator " + op->Type () + " running: "
341
323
<< memory::memory_usage (place_);
342
324
}
343
- if (FLAGS_check_nan_inf) {
344
- for (auto & vname : op->OutputVars (true )) {
345
- auto * var = local_scope->FindVar (vname);
346
- if (var == nullptr ) continue ;
347
- if (var->IsType <framework::LoDTensor>()) {
348
- CheckTensorNANOrInf (vname, var->Get <framework::LoDTensor>());
349
- }
350
- }
351
- }
352
325
}
353
326
platform::DeviceContextPool::Instance ().Get (place_)->Wait ();
354
327
if (create_vars && create_local_scope) {
0 commit comments