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:
|
if len(example) < max_len:
|
||||||
example += [pad_value] * (max_len - len(example))
|
example += [pad_value] * (max_len - len(example))
|
||||||
tensor = torch.LongTensor(batch)
|
tensor = torch.LongTensor(batch)
|
||||||
if device != -1:
|
tensor = tensor.to(device)
|
||||||
tensor = tensor.cuda(device)
|
|
||||||
else:
|
else:
|
||||||
padded = self.pad(batch)
|
padded = self.pad(batch)
|
||||||
tensor = self.numericalize(padded, device=device, train=train, **kwargs)
|
tensor = self.numericalize(padded, device=device, train=train, **kwargs)
|
||||||
|
@ -358,13 +357,11 @@ class Field(RawField):
|
||||||
if self.sequential and not self.batch_first:
|
if self.sequential and not self.batch_first:
|
||||||
arr.t_()
|
arr.t_()
|
||||||
lim_arr.t_()
|
lim_arr.t_()
|
||||||
if device == -1:
|
if self.sequential:
|
||||||
if self.sequential:
|
arr = arr.contiguous()
|
||||||
arr = arr.contiguous()
|
lim_arr = lim_arr.contiguous()
|
||||||
lim_arr = lim_arr.contiguous()
|
arr = arr.to(device)
|
||||||
else:
|
lim_arr = lim_arr.to(device)
|
||||||
arr = arr.cuda(device)
|
|
||||||
lim_arr = lim_arr.cuda(device)
|
|
||||||
# if self.include_lengths:
|
# if self.include_lengths:
|
||||||
# lengths = lengths.cuda(device)
|
# lengths = lengths.cuda(device)
|
||||||
if self.include_lengths:
|
if self.include_lengths:
|
||||||
|
|
Loading…
Reference in New Issue