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
6ed6ed29
Unverified
Commit
6ed6ed29
authored
Nov 15, 2022
by
Yih-Dar
Committed by
GitHub
Nov 15, 2022
Browse files
fix device issue (#20227)
Co-authored-by:
ydshieh
<
ydshieh@users.noreply.github.com
>
parent
d3d5fa3e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
3 deletions
+3
-3
src/transformers/models/tapas/modeling_tapas.py
src/transformers/models/tapas/modeling_tapas.py
+3
-3
No files found.
src/transformers/models/tapas/modeling_tapas.py
View file @
6ed6ed29
...
...
@@ -1784,9 +1784,9 @@ def _segment_reduce(values, index, segment_reduce_fn, name):
# changed "view" by "reshape" in the following line
flat_values
=
values
.
reshape
(
flattened_shape
.
tolist
())
out
=
torch
.
zeros
(
int
(
flat_index
.
num_segments
),
dtype
=
flat_values
.
d
typ
e
)
out
=
torch
.
zeros
(
int
(
flat_index
.
num_segments
),
dtype
=
torch
.
float
,
device
=
flat_values
.
d
evic
e
)
segment_means
=
out
.
scatter_reduce
(
dim
=
0
,
index
=
flat_index
.
indices
.
long
(),
src
=
flat_values
,
reduce
=
segment_reduce_fn
,
include_self
=
False
dim
=
0
,
index
=
flat_index
.
indices
.
long
(),
src
=
flat_values
.
float
()
,
reduce
=
segment_reduce_fn
,
include_self
=
False
)
# Unflatten the values.
...
...
@@ -1799,7 +1799,7 @@ def _segment_reduce(values, index, segment_reduce_fn, name):
dim
=
0
,
)
output_values
=
segment_means
.
clone
().
view
(
new_shape
.
tolist
())
output_values
=
segment_means
.
clone
().
view
(
new_shape
.
tolist
())
.
to
(
values
.
dtype
)
output_index
=
range_index_map
(
index
.
batch_shape
(),
index
.
num_segments
)
return
output_values
,
output_index
...
...
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