update field for torch 0.4
This commit is contained in:
parent
b82b510de5
commit
2838e23be1
|
@ -198,8 +198,7 @@ class Field(RawField):
|
|||
if len(example) < max_len:
|
||||
example += [pad_value] * (max_len - len(example))
|
||||
tensor = torch.LongTensor(batch)
|
||||
if device != -1:
|
||||
tensor = tensor.cuda(device)
|
||||
tensor = tensor.to(device)
|
||||
else:
|
||||
padded = self.pad(batch)
|
||||
tensor = self.numericalize(padded, device=device, train=train, **kwargs)
|
||||
|
@ -358,13 +357,11 @@ class Field(RawField):
|
|||
if self.sequential and not self.batch_first:
|
||||
arr.t_()
|
||||
lim_arr.t_()
|
||||
if device == -1:
|
||||
if self.sequential:
|
||||
arr = arr.contiguous()
|
||||
lim_arr = lim_arr.contiguous()
|
||||
else:
|
||||
arr = arr.cuda(device)
|
||||
lim_arr = lim_arr.cuda(device)
|
||||
arr = arr.to(device)
|
||||
lim_arr = lim_arr.to(device)
|
||||
# if self.include_lengths:
|
||||
# lengths = lengths.cuda(device)
|
||||
if self.include_lengths:
|
||||
|
|
Loading…
Reference in New Issue