Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
predtuner
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
predtuner
Commits
d260f0a6
Commit
d260f0a6
authored
4 years ago
by
Yifan Zhao
Browse files
Options
Downloads
Patches
Plain Diff
Added integrated test case (also example)
parent
f9557aac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
predtuner/approxapp.py
+5
-1
5 additions, 1 deletion
predtuner/approxapp.py
test/integrated_tuning.py
+27
-0
27 additions, 0 deletions
test/integrated_tuning.py
with
32 additions
and
1 deletion
predtuner/approxapp.py
+
5
−
1
View file @
d260f0a6
...
...
@@ -3,8 +3,8 @@ import logging
from
pathlib
import
Path
from
typing
import
Dict
,
Generic
,
List
,
NamedTuple
,
Optional
,
Tuple
,
TypeVar
,
Union
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
opentuner.measurement.interface
import
MeasurementInterface
from
opentuner.resultsdb.models
import
Configuration
,
Result
from
opentuner.search.manipulator
import
ConfigurationManipulator
,
EnumParameter
...
...
@@ -162,12 +162,16 @@ class ApproxTuner(Generic[T]):
return
[
configs
[
i
]
for
i
in
taken_idx
]
def
write_configs_to_dir
(
self
,
directory
:
PathLike
):
import
os
from
jsonpickle
import
encode
if
not
self
.
tuned
:
raise
RuntimeError
(
f
"
No tuning session has been run; call self.tune() first.
"
)
directory
=
Path
(
directory
)
os
.
makedirs
(
directory
,
exist_ok
=
True
)
encode
(
self
.
kept_configs
,
directory
)
def
plot_configs
(
self
)
->
plt
.
Figure
:
...
...
This diff is collapsed.
Click to expand it.
test/integrated_tuning.py
0 → 100644
+
27
−
0
View file @
d260f0a6
import
site
from
pathlib
import
Path
import
torch
from
torch.utils.data.dataloader
import
DataLoader
from
torch.utils.data.dataset
import
Subset
site
.
addsitedir
(
Path
(
__file__
).
absolute
().
parent
.
parent
)
from
model_zoo
import
CIFAR
,
VGG16Cifar10
from
predtuner
import
TorchApp
,
accuracy
,
config_pylogger
,
get_knobs_from_file
msg_logger
=
config_pylogger
(
output_dir
=
"
tuner_results/logs
"
,
verbose
=
True
)
dataset
=
CIFAR
.
from_file
(
"
model_data/cifar10/input.bin
"
,
"
model_data/cifar10/labels.bin
"
)
tune_loader
=
DataLoader
(
Subset
(
dataset
,
range
(
5000
)),
batch_size
=
500
)
calib_loader
=
DataLoader
(
Subset
(
dataset
,
range
(
5000
,
10000
)),
batch_size
=
500
)
module
=
VGG16Cifar10
()
module
.
load_state_dict
(
torch
.
load
(
"
model_data/vgg16_cifar10.pth.tar
"
))
app
=
TorchApp
(
"
TestTorchApp
"
,
module
,
tune_loader
,
calib_loader
,
get_knobs_from_file
(),
accuracy
,
)
baseline
,
_
=
app
.
measure_qos_perf
({},
False
)
tuner
=
app
.
get_tuner
()
tuner
.
tune
(
500
,
2.1
,
3.0
,
True
,
50
)
tuner
.
write_configs_to_dir
(
"
tuner_results/test
"
)
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