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
ModelZoo
donut_pytorch
Commits
1f4b27c6
Commit
1f4b27c6
authored
Nov 14, 2022
by
Geewook Kim
Browse files
feat: remove bfloat16 for cpu
parent
6f8a40da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
6 deletions
+0
-6
app.py
app.py
+0
-2
donut/model.py
donut/model.py
+0
-2
test.py
test.py
+0
-2
No files found.
app.py
View file @
1f4b27c6
...
@@ -52,8 +52,6 @@ if __name__ == "__main__":
...
@@ -52,8 +52,6 @@ if __name__ == "__main__":
pretrained_model
.
half
()
pretrained_model
.
half
()
device
=
torch
.
device
(
"cuda"
)
device
=
torch
.
device
(
"cuda"
)
pretrained_model
.
to
(
device
)
pretrained_model
.
to
(
device
)
else
:
pretrained_model
.
encoder
.
to
(
torch
.
bfloat16
)
pretrained_model
.
eval
()
pretrained_model
.
eval
()
...
...
donut/model.py
View file @
1f4b27c6
...
@@ -443,8 +443,6 @@ class DonutModel(PreTrainedModel):
...
@@ -443,8 +443,6 @@ class DonutModel(PreTrainedModel):
if
self
.
device
.
type
==
"cuda"
:
# half is not compatible in cpu implementation.
if
self
.
device
.
type
==
"cuda"
:
# half is not compatible in cpu implementation.
image_tensors
=
image_tensors
.
half
()
image_tensors
=
image_tensors
.
half
()
image_tensors
=
image_tensors
.
to
(
self
.
device
)
image_tensors
=
image_tensors
.
to
(
self
.
device
)
else
:
image_tensors
=
image_tensors
.
to
(
torch
.
bfloat16
)
if
prompt_tensors
is
None
:
if
prompt_tensors
is
None
:
prompt_tensors
=
self
.
decoder
.
tokenizer
(
prompt
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
)[
"input_ids"
]
prompt_tensors
=
self
.
decoder
.
tokenizer
(
prompt
,
add_special_tokens
=
False
,
return_tensors
=
"pt"
)[
"input_ids"
]
...
...
test.py
View file @
1f4b27c6
...
@@ -24,8 +24,6 @@ def test(args):
...
@@ -24,8 +24,6 @@ def test(args):
if
torch
.
cuda
.
is_available
():
if
torch
.
cuda
.
is_available
():
pretrained_model
.
half
()
pretrained_model
.
half
()
pretrained_model
.
to
(
"cuda"
)
pretrained_model
.
to
(
"cuda"
)
else
:
pretrained_model
.
encoder
.
to
(
torch
.
bfloat16
)
pretrained_model
.
eval
()
pretrained_model
.
eval
()
...
...
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