Fix tensorizer on GPU

This commit is contained in:
Matthew Honnibal 2017-11-05 15:34:40 +01:00
parent 6e5181bbaa
commit 2b35bb76ad
2 changed files with 10 additions and 2 deletions

View File

@ -415,7 +415,11 @@ class Tagger(Pipe):
vocab.morphology.assign_tag_id(&doc.c[j], tag_id)
idx += 1
if tensors is not None:
doc.extend_tensor(tensors[i])
if isinstance(doc.tensor, numpy.ndarray) \
and not isinstance(tensors[i], numpy.ndarray):
doc.extend_tensor(tensors[i].get())
else:
doc.extend_tensor(tensors[i])
doc.is_tagged = True
def update(self, docs, golds, drop=0., sgd=None, losses=None):

View File

@ -751,7 +751,11 @@ cdef class Parser:
for j in range(doc.length):
doc.c[j] = state.c._sent[j]
if tensors is not None:
doc.extend_tensor(tensors[i])
if isinstance(doc.tensor, numpy.ndarray) \
and not isinstance(tensors[i], numpy.ndarray):
doc.extend_tensor(tensors[i].get())
else:
doc.extend_tensor(tensors[i])
self.moves.finalize_doc(doc)
for hook in self.postprocesses: