From aa626840af8943f59b63c453569f3b61775d7b5c Mon Sep 17 00:00:00 2001 From: Dmytro Dzhulgakov Date: Mon, 11 Feb 2019 23:04:59 -0800 Subject: [PATCH] Fix NERPredictor for zero initialization Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/16931 Reviewed By: dragonxlwang Differential Revision: D14016749 fbshipit-source-id: b5512c52cef77651bdba1e31f588ea649daacdd9 --- caffe2/operators/pack_segments.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/caffe2/operators/pack_segments.cc b/caffe2/operators/pack_segments.cc index 8e82ed0..edbaa16 100644 --- a/caffe2/operators/pack_segments.cc +++ b/caffe2/operators/pack_segments.cc @@ -67,11 +67,6 @@ bool PackSegmentsOp::DoRunWithType2() { presence_mask_data = presence_mask->template mutable_data(); } - if (!data.size(0)) { - // Return empty output (with the proper shape) - return true; - } - // Do padding if (output->template IsType()) { math::Set( @@ -80,6 +75,11 @@ bool PackSegmentsOp::DoRunWithType2() { output->template mutable_data(), &context_); } + if (!data.size(0)) { + // Return empty output (with the proper shape) + return true; + } + if (return_presence_mask_) { memset(presence_mask_data, (int)false, presence_mask->numel()); } -- 2.7.4