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
5493c10e
Unverified
Commit
5493c10e
authored
Mar 15, 2022
by
Hyeonsoo Lee
Committed by
GitHub
Mar 14, 2022
Browse files
Add type hints for PoolFormer in Pytorch (#16121)
parent
6c2f3ed7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
src/transformers/models/poolformer/modeling_poolformer.py
src/transformers/models/poolformer/modeling_poolformer.py
+12
-7
No files found.
src/transformers/models/poolformer/modeling_poolformer.py
View file @
5493c10e
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
import
collections.abc
import
collections.abc
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
typing
import
Optional
,
Tuple
from
typing
import
Optional
,
Tuple
,
Union
import
torch
import
torch
import
torch.utils.checkpoint
import
torch.utils.checkpoint
...
@@ -379,7 +379,12 @@ class PoolFormerModel(PoolFormerPreTrainedModel):
...
@@ -379,7 +379,12 @@ class PoolFormerModel(PoolFormerPreTrainedModel):
modality
=
"vision"
,
modality
=
"vision"
,
expected_output
=
_EXPECTED_OUTPUT_SHAPE
,
expected_output
=
_EXPECTED_OUTPUT_SHAPE
,
)
)
def
forward
(
self
,
pixel_values
=
None
,
output_hidden_states
=
None
,
return_dict
=
None
):
def
forward
(
self
,
pixel_values
:
Optional
[
torch
.
FloatTensor
]
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
)
->
Union
[
Tuple
,
PoolFormerModelOutput
]:
output_hidden_states
=
(
output_hidden_states
=
(
output_hidden_states
if
output_hidden_states
is
not
None
else
self
.
config
.
output_hidden_states
output_hidden_states
if
output_hidden_states
is
not
None
else
self
.
config
.
output_hidden_states
)
)
...
@@ -446,11 +451,11 @@ class PoolFormerForImageClassification(PoolFormerPreTrainedModel):
...
@@ -446,11 +451,11 @@ class PoolFormerForImageClassification(PoolFormerPreTrainedModel):
)
)
def
forward
(
def
forward
(
self
,
self
,
pixel_values
=
None
,
pixel_values
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
):
)
->
Union
[
Tuple
,
PoolFormerClassifierOutput
]
:
r
"""
r
"""
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
Labels for computing the image classification/regression loss. Indices should be in `[0, ...,
...
...
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