Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SwissArmyTransformer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
thukeg
SwissArmyTransformer
Commits
bcbc6120
Commit
bcbc6120
authored
3 years ago
by
Ming Ding
Browse files
Options
Downloads
Patches
Plain Diff
fix basemodel typo and old hooks name
parent
be5e6c90
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SwissArmyTransformer/model/base_model.py
+2
-2
2 additions, 2 deletions
SwissArmyTransformer/model/base_model.py
with
2 additions
and
2 deletions
SwissArmyTransformer/model/base_model.py
+
2
−
2
View file @
bcbc6120
...
@@ -106,7 +106,7 @@ class BaseModel(torch.nn.Module):
...
@@ -106,7 +106,7 @@ class BaseModel(torch.nn.Module):
def
collect_hooks_
(
self
):
def
collect_hooks_
(
self
):
names
=
[
'
word_embedding_forward
'
,
'
position_embedding_forward
'
,
names
=
[
'
word_embedding_forward
'
,
'
position_embedding_forward
'
,
'
attention_forward
'
,
'
cross_attention_forward
'
,
'
mlp_forward
'
,
'
final_forward
'
,
'
layer_forward
'
,
'
attention_forward
'
,
'
cross_attention_forward
'
,
'
mlp_forward
'
,
'
final_forward
'
,
'
layer_forward
'
,
'
branch
_embedding_forward
'
,
'
branch_final_forward
'
,
'
cross_layer
_embedding_forward
'
,
'
attention_fn
'
'
attention_fn
'
]
]
hooks
=
{}
hooks
=
{}
...
@@ -115,7 +115,7 @@ class BaseModel(torch.nn.Module):
...
@@ -115,7 +115,7 @@ class BaseModel(torch.nn.Module):
for
mixin_name
,
m
in
self
.
mixins
.
items
():
for
mixin_name
,
m
in
self
.
mixins
.
items
():
if
hasattr
(
m
,
name
):
if
hasattr
(
m
,
name
):
if
name
in
hooks
:
# if this hook name is already registered
if
name
in
hooks
:
# if this hook name is already registered
if
hasattr
(
getattr
(
m
,
name
),
'
non_confict
'
):
if
hasattr
(
getattr
(
m
,
name
),
'
non_conf
l
ict
'
):
hooks
[
name
]
=
partial
(
getattr
(
m
,
name
),
old_impl
=
hooks
[
name
])
hooks
[
name
]
=
partial
(
getattr
(
m
,
name
),
old_impl
=
hooks
[
name
])
hook_origins
[
name
]
=
mixin_name
+
'
->
'
+
hook_origins
[
name
]
hook_origins
[
name
]
=
mixin_name
+
'
->
'
+
hook_origins
[
name
]
else
:
# conflict
else
:
# conflict
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment