From 0fd4a04abdc6f411ebb77d7a389108e951223c7e Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Fri, 29 Dec 2017 13:10:53 +0800 Subject: [PATCH] Remove debug codes --- paddle/framework/tensor_impl.h | 13 ++----------- paddle/operators/fill_constant_op.cc | 1 - paddle/operators/shrink_rnn_memory_op.cc | 1 - paddle/operators/while_op.cc | 23 ----------------------- 4 files changed, 2 insertions(+), 36 deletions(-) diff --git a/paddle/framework/tensor_impl.h b/paddle/framework/tensor_impl.h index 0161ed8c4..6c6f298ed 100644 --- a/paddle/framework/tensor_impl.h +++ b/paddle/framework/tensor_impl.h @@ -134,17 +134,8 @@ inline void* Tensor::mutable_data(platform::Place place, std::type_index type) { #endif offset_ = 0; } - void* buf = reinterpret_cast( - reinterpret_cast(holder_->ptr()) + offset_); - if (type.hash_code() == typeid(float).hash_code() || - type.hash_code() == typeid(double).hash_code()) { - float* tmp = (float*)(buf); - for (int64_t i = 0; i < numel(); ++i) { - tmp[i] = NAN; - } - } - - return buf; + return reinterpret_cast(reinterpret_cast(holder_->ptr()) + + offset_); } inline void* Tensor::mutable_data(platform::Place place) { diff --git a/paddle/operators/fill_constant_op.cc b/paddle/operators/fill_constant_op.cc index 196c380c7..dcd43a30c 100644 --- a/paddle/operators/fill_constant_op.cc +++ b/paddle/operators/fill_constant_op.cc @@ -51,7 +51,6 @@ class FillConstantOp : public framework::OperatorBase { platform::DeviceContextPool &pool = platform::DeviceContextPool::Instance(); auto &dev_ctx = *pool.Get(dev_place); - VLOG(10) << "FillConstant to " << &out; math::set_constant(dev_ctx, &out, value); } }; diff --git a/paddle/operators/shrink_rnn_memory_op.cc b/paddle/operators/shrink_rnn_memory_op.cc index 9ef473e72..b37269b47 100644 --- a/paddle/operators/shrink_rnn_memory_op.cc +++ b/paddle/operators/shrink_rnn_memory_op.cc @@ -116,7 +116,6 @@ class ShrinkRNNMemoryGradOp : public ArrayOp { auto height = dout_tensor.dims()[0]; auto slice = dx_tensor.Slice(0, static_cast(height)); framework::CopyFrom(dout_tensor, dout_tensor.place(), dev_ctx, &slice); - VLOG(10) << dx_tensor.dims()[0] << ", " << height; if (dx_tensor.dims()[0] > height) { auto rest_tensor = dx_tensor.Slice( static_cast(height), static_cast(dx_tensor.dims()[0])); diff --git a/paddle/operators/while_op.cc b/paddle/operators/while_op.cc index 341c163aa..728ef6079 100644 --- a/paddle/operators/while_op.cc +++ b/paddle/operators/while_op.cc @@ -12,7 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include #include #include "paddle/framework/executor.h" #include "paddle/framework/lod_tensor_array.h" @@ -195,36 +194,14 @@ class WhileGradOp : public framework::OperatorBase { } } - auto check_var_no_nan = [](const framework::Scope &scope, - const std::string &var_name) { - auto *var = scope.FindVar(var_name); - if (var->IsType()) { - VLOG(10) << "Checking " << var_name; - PADDLE_ENFORCE(!framework::HasNAN(var->Get()), - "%s has NAN", var_name); - if (var->Get().type() == - typeid(float)) { // NOLINT - auto &tensor = var->Get(); - auto *buf = tensor.data(); - for (int64_t i = 0; i < tensor.numel(); ++i) { - PADDLE_ENFORCE(!std::isnan(buf[i])); - } - VLOG(10) << buf[0]; - } - } - }; - check_var_no_nan(cur_scope, inside_grad_name); auto new_inside_name = cur_scope.Rename(inside_grad_name); - check_var_no_nan(cur_scope, new_inside_name); auto sum_op = framework::OpRegistry::CreateOp( "sum", {{"X", {pg_names[param_id], new_inside_name}}}, {{"Out", {pg_names[param_id]}}}, framework::AttributeMap{}); sum_op->Run(cur_scope, dev_place); - check_var_no_nan(scope, pg_names[param_id]); cur_scope.Rename(new_inside_name, inside_grad_name); } } - VLOG(1) << "Complete WhileOpGrad"; } }; -- GitLab