From 1a8cbb679989be672afd76a72f85fe694769a049 Mon Sep 17 00:00:00 2001 From: JiabinYang Date: Mon, 24 Dec 2018 10:14:59 +0000 Subject: [PATCH] test=develop, accelerate_hs_op and add prefetch with is_sparse --- paddle/fluid/operators/hierarchical_sigmoid_op.h | 3 ++- python/paddle/fluid/layers/nn.py | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/operators/hierarchical_sigmoid_op.h b/paddle/fluid/operators/hierarchical_sigmoid_op.h index b47bf49ecb7..1a7ca963010 100644 --- a/paddle/fluid/operators/hierarchical_sigmoid_op.h +++ b/paddle/fluid/operators/hierarchical_sigmoid_op.h @@ -40,8 +40,9 @@ using platform::Transform; static std::vector PathToRows(const framework::LoDTensor& path) { std::set rows; + const int64_t* paths = path.data(); for (int64_t i = 0; i < path.numel(); ++i) { - int64_t row = path.data()[i]; + int64_t row = paths[i]; if (row < 0) { continue; } diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 861bc320261..6379031ee49 100644 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -5013,9 +5013,10 @@ def nce(input, else: num_neg_samples = int(num_neg_samples) - remote_prefetch = False - if os.environ.get('PADDLE_ENABLE_REMOTE_PREFETCH'): - remote_prefetch = True + remote_prefetch = is_sparse + print( + "With sparse mode, if your models has only small parameter prefetch may cause speed down" + ) attrs = { 'num_total_classes': int(num_total_classes), @@ -5133,10 +5134,10 @@ def hsigmoid(input, pass weights = None - remote_prefetch = False - if os.environ.get('PADDLE_ENABLE_REMOTE_PREFETCH'): - remote_prefetch = True - + remote_prefetch = is_sparse + print( + "With sparse mode, if your models has only small parameter prefetch may cause speed down" + ) if not is_custom: weights = helper.create_parameter( attr=helper.param_attr, -- GitLab