-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Bugfix: initializing all tensors and parameters of the ConditionalRandomField
model on the proper device
#5335
Conversation
…ndomField` in the proper device
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one little change, and this is ready to go!
@@ -364,7 +364,7 @@ def viterbi_tags( | |||
# Augment transitions matrix with start and end transitions | |||
start_tag = num_tags | |||
end_tag = num_tags + 1 | |||
transitions = torch.Tensor(num_tags + 2, num_tags + 2).fill_(-10000.0) | |||
transitions = torch.empty(num_tags + 2, num_tags + 2, device=logits.device).fill_(-10000.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use torch.full()
, so we can create the tensor in one go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will also be faster!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: 84d4e20
Ah, it also needs an entry in the changelog. So two little changes I guess. |
Thank you! |
Bugfix:
crf_tagger
was doing most of the computations on the CPU, as theConditionalRandomField
model's parameters and some necessary tensors were initialized on the wrong device.Fixes #2884 .
Changes proposed in this pull request:
ConditionalRandomField
'stransitions
andtag_sequence
tensors are initialized on the proper deviceBefore submitting
section of the
CONTRIBUTING
docs.Writing docstrings section of the
CONTRIBUTING
docs.After submitting
codecov/patch
reports high test coverage (at least 90%).You can find this under the "Actions" tab of the pull request once the other checks have finished.