Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
3ccc2701
Unverified
Commit
3ccc2701
authored
Sep 27, 2021
by
Xiaohan Zou
Committed by
GitHub
Sep 27, 2021
Browse files
Fix type annotations for `distributed_concat()` (#13746)
* Fix type annotations for `distributed_concat()` * Use Any
parent
e0d31a89
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/trainer_pt_utils.py
src/transformers/trainer_pt_utils.py
+2
-2
No files found.
src/transformers/trainer_pt_utils.py
View file @
3ccc2701
...
@@ -25,7 +25,7 @@ import warnings
...
@@ -25,7 +25,7 @@ import warnings
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
logging
import
StreamHandler
from
logging
import
StreamHandler
from
typing
import
Dict
,
Iterator
,
List
,
Optional
,
Union
from
typing
import
Any
,
Dict
,
Iterator
,
List
,
Optional
,
Union
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
...
@@ -157,7 +157,7 @@ def nested_xla_mesh_reduce(tensors, name):
...
@@ -157,7 +157,7 @@ def nested_xla_mesh_reduce(tensors, name):
raise
ImportError
(
"Torch xla must be installed to use `nested_xla_mesh_reduce`"
)
raise
ImportError
(
"Torch xla must be installed to use `nested_xla_mesh_reduce`"
)
def
distributed_concat
(
tensor
:
"torch.Tensor"
,
num_total_examples
:
Optional
[
int
]
=
None
)
->
torch
.
Tensor
:
def
distributed_concat
(
tensor
:
Any
,
num_total_examples
:
Optional
[
int
]
=
None
)
->
Any
:
try
:
try
:
if
isinstance
(
tensor
,
(
tuple
,
list
)):
if
isinstance
(
tensor
,
(
tuple
,
list
)):
return
type
(
tensor
)(
distributed_concat
(
t
,
num_total_examples
)
for
t
in
tensor
)
return
type
(
tensor
)(
distributed_concat
(
t
,
num_total_examples
)
for
t
in
tensor
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment