forked from HIT-SCIR/ltp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
修正 PyTorch 1.8 兼容性问题 / PyTorch 1.8 compatability fix (HIT-SCIR#519)
- Loading branch information
Showing
2 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,16 @@ | |
# Author: Yunlong Feng <[email protected]> | ||
|
||
import torch | ||
from torch._six import int_classes, string_classes, container_abcs | ||
from torch._six import string_classes | ||
from torch.utils.data._utils.collate import np_str_obj_array_pattern, default_collate_err_msg_format | ||
|
||
_TORCH_MAJOR, _TORCH_MINOR = map(int, torch.__version__.split('.')[0:2]) | ||
|
||
if _TORCH_MAJOR < 1 or (_TORCH_MAJOR == 1 and _TORCH_MINOR < 8): | ||
from torch._six import int_classes, container_abcs | ||
else: | ||
int_classes = int | ||
import collections.abc as container_abcs | ||
|
||
def collate(batch): | ||
r"""Puts each data field into a tensor with outer dimension batch size""" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,13 @@ | |
# Author: Yunlong Feng <[email protected]> | ||
|
||
import torch | ||
from torch._six import container_abcs | ||
|
||
_TORCH_MAJOR, _TORCH_MINOR = map(int, torch.__version__.split('.')[0:2]) | ||
|
||
if _TORCH_MAJOR < 1 or (_TORCH_MAJOR == 1 and _TORCH_MINOR < 8): | ||
from torch._six import container_abcs | ||
else: | ||
import collections.abc as container_abcs | ||
|
||
|
||
def map2device(batch, device=torch.device('cpu')): | ||
|