Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
yapt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
llvm
yapt
Commits
ae767db6
Commit
ae767db6
authored
3 years ago
by
Yifan Zhao
Browse files
Options
Downloads
Patches
Plain Diff
Add deepcopy / use implicit device
parent
b3b5a2a2
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
yapt/struct_pruning/search_prune.py
+4
-5
4 additions, 5 deletions
yapt/struct_pruning/search_prune.py
with
4 additions
and
5 deletions
yapt/struct_pruning/search_prune.py
+
4
−
5
View file @
ae767db6
import
logging
from
copy
import
deepcopy
from
typing
import
Dict
,
List
,
NamedTuple
import
opentuner
as
ot
...
...
@@ -61,7 +62,7 @@ class AutotunedPruner(StructuredPruner):
from
opentuner.tuningrunmain
import
TuningRunMain
# 1. Run tuning
measurer
=
PruningMeasurer
(
self
.
ot_args
,
self
,
module
,
groups
)
measurer
=
PruningMeasurer
(
self
.
ot_args
,
self
,
deepcopy
(
module
)
,
groups
)
trm
=
TuningRunMain
(
measurer
,
self
.
ot_args
)
# A little bit of hack to get the _real_ progress when duplicated configs exist
measurer
.
set_progress_getter
(
lambda
:
trm
.
search_driver
.
test_count
)
...
...
@@ -75,9 +76,7 @@ class AutotunedPruner(StructuredPruner):
def
make_pruned_copy
(
self
,
module
:
pl
.
LightningModule
,
config
:
Dict
[
str
,
List
[
int
]]
):
import
copy
module
=
copy
.
deepcopy
(
module
)
module
=
deepcopy
(
module
)
assert
self
.
args
is
not
None
self
.
_intern_prune_module_
(
module
,
self
.
args
,
config
)
return
module
...
...
@@ -86,7 +85,7 @@ class AutotunedPruner(StructuredPruner):
# Calibrate on a small portion of training set and get accuracy on validation set.
# (We're already inside torch.no_grad() here)
n_im
=
0
module
=
module
.
train
()
.
cuda
()
module
=
module
.
train
()
loader
=
module
.
train_dataloader
()
assert
isinstance
(
loader
,
DataLoader
)
# Not a list of DataLoaders
for
batch
in
loader
:
...
...
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