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
dc72fd7e
"examples/vscode:/vscode.git/clone" did not exist on "64bdbd888c78dcef5aeaeabc842e12981c8aae7a"
Unverified
Commit
dc72fd7e
authored
Jul 03, 2024
by
Ella Charlaix
Committed by
GitHub
Jul 03, 2024
Browse files
Requires for torch.tensor before casting (#31755)
parent
7f91f168
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
src/transformers/utils/generic.py
src/transformers/utils/generic.py
+2
-2
No files found.
src/transformers/utils/generic.py
View file @
dc72fd7e
...
...
@@ -762,7 +762,7 @@ def torch_int(x):
import
torch
return
x
.
to
(
torch
.
int64
)
if
torch
.
jit
.
is_tracing
()
else
int
(
x
)
return
x
.
to
(
torch
.
int64
)
if
torch
.
jit
.
is_tracing
()
and
isinstance
(
x
,
torch
.
Tensor
)
else
int
(
x
)
def
torch_float
(
x
):
...
...
@@ -774,7 +774,7 @@ def torch_float(x):
import
torch
return
x
.
to
(
torch
.
float32
)
if
torch
.
jit
.
is_tracing
()
else
int
(
x
)
return
x
.
to
(
torch
.
float32
)
if
torch
.
jit
.
is_tracing
()
and
isinstance
(
x
,
torch
.
Tensor
)
else
int
(
x
)
def
filter_out_non_signature_kwargs
(
extra
:
Optional
[
list
]
=
None
):
...
...
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