diff options
author | Chris Dyer <redpony@gmail.com> | 2014-12-17 15:03:48 -0500 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-12-17 15:03:48 -0500 |
commit | 796768086a687d3f1856fef6489c34fe4d373642 (patch) | |
tree | 154a46bf784107f5abdc77f2bd4f10b287b623f7 /decoder/ffset.cc | |
parent | c915af2347a676b1f3b11dc4c0865c4bdb7ca609 (diff) | |
parent | 0bf82a2b969c8022bd5ad490b28a2df27e03e919 (diff) |
Merge pull request #61 from kho/ignore_state
Add IgnoredStateSize() to FeatureFunction
Diffstat (limited to 'decoder/ffset.cc')
-rw-r--r-- | decoder/ffset.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/decoder/ffset.cc b/decoder/ffset.cc index 5820f421..8ba70389 100644 --- a/decoder/ffset.cc +++ b/decoder/ffset.cc @@ -14,6 +14,11 @@ ModelSet::ModelSet(const vector<double>& w, const vector<const FeatureFunction*> for (int i = 0; i < models_.size(); ++i) { model_state_pos_[i] = state_size_; state_size_ += models_[i]->StateSize(); + int num_ignored_bytes = models_[i]->IgnoredStateSize(); + if (num_ignored_bytes > 0) { + ranges_to_erase_.push_back( + {state_size_ - num_ignored_bytes, state_size_}); + } } } @@ -70,3 +75,13 @@ void ModelSet::AddFinalFeatures(const FFState& state, HG::Edge* edge,SentenceMet edge->edge_prob_.logeq(edge->feature_values_.dot(weights_)); } +bool ModelSet::NeedsStateErasure() const { return !ranges_to_erase_.empty(); } + +void ModelSet::EraseIgnoredBytes(FFState* state) const { + // TODO: can we memset? + for (const auto& range : ranges_to_erase_) { + for (int i = range.first; i < range.second; ++i) { + (*state)[i] = 0; + } + } +} |