From 2857dac260bc0c858d1338a76cff1018ea67a877 Mon Sep 17 00:00:00 2001 From: xuezhong Date: Thu, 31 Jan 2019 13:21:17 +0000 Subject: [PATCH] add assert for clip and remove print --- paddle/fluid/operators/lstmp_op.h | 19 ------------------- python/paddle/fluid/layers/nn.py | 5 +++++ 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/paddle/fluid/operators/lstmp_op.h b/paddle/fluid/operators/lstmp_op.h index 9cad0bfd0..94040c597 100644 --- a/paddle/fluid/operators/lstmp_op.h +++ b/paddle/fluid/operators/lstmp_op.h @@ -94,25 +94,6 @@ class LSTMPKernel : public framework::OpKernel { PADDLE_THROW("unsupported activation type"); } - void Print(const Tensor& t, std::string name) const { - VLOG(1) << name << "size = " << t.numel(); - size_t size = t.numel(); - T* d = t.data(); -#ifdef PADDLE_WITH_CUDA - std::vector vec; - platform::DeviceContextPool::Instance().Get(t.place())->Wait(); - if (platform::is_gpu_place(t.place())) { - vec.resize(size); - cudaMemcpy(vec.data(), d, sizeof(T) * size, cudaMemcpyDeviceToHost); - d = vec.data(); - } -#endif - VLOG(1) << name << " data_ptr = " << static_cast(d); - for (size_t i = 0; i < size; i++) { - VLOG(1) << d[i] << ","; - } - } - void Compute(const framework::ExecutionContext& ctx) const override { auto* input = ctx.Input("Input"); auto* weight = ctx.Input("Weight"); diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index b5f6b5d44..c56fd1c91 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -862,6 +862,11 @@ def dynamic_lstmp(input, 'The shape of c0 should be (batch_size, %d)' % size inputs['C0'] = c_0 + if cell_clip: + assert cell_clip >= 0, "cell_clip should not be negtive." + if proj_clip: + assert proj_clip >= 0, "proj_clip should not be negtive." + helper.append_op( type='lstmp', inputs=inputs, -- GitLab