Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
18d0ad31
Commit
18d0ad31
authored
Jul 28, 2019
by
peterjc123
Committed by
Yao Wang
Jul 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the x86 auto-tune tutorial (#3609)
parent
fbe42c26
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
tutorials/autotvm/tune_relay_x86.py
+7
-3
No files found.
tutorials/autotvm/tune_relay_x86.py
View file @
18d0ad31
...
...
@@ -64,7 +64,7 @@ def get_network(name, batch_size):
# an example for mxnet model
from
mxnet.gluon.model_zoo.vision
import
get_model
block
=
get_model
(
'resnet18_v1'
,
pretrained
=
True
)
mod
,
params
=
relay
.
frontend
.
from_mxnet
(
block
,
shape
=
{
'data'
:
input_shape
},
dtype
=
dtype
)
mod
,
params
=
relay
.
frontend
.
from_mxnet
(
block
,
shape
=
{
input_name
:
input_shape
},
dtype
=
dtype
)
net
=
mod
[
"main"
]
net
=
relay
.
Function
(
net
.
params
,
relay
.
nn
.
softmax
(
net
.
body
),
None
,
net
.
type_params
,
net
.
attrs
)
mod
=
relay
.
Module
.
from_expr
(
net
)
...
...
@@ -86,6 +86,10 @@ model_name = "resnet-18"
log_file
=
"
%
s.log"
%
model_name
graph_opt_sch_file
=
"
%
s_graph_opt.log"
%
model_name
# Set the input name of the graph
# For ONNX models, it is typically "0".
input_name
=
"data"
# Set number of threads used for tuning based on the number of
# physical CPU cores on your machine.
num_threads
=
1
...
...
@@ -166,7 +170,7 @@ def tune_kernels(tasks,
def
tune_graph
(
graph
,
dshape
,
records
,
opt_sch_file
,
use_DP
=
True
):
target_op
=
[
relay
.
nn
.
conv2d
]
Tuner
=
DPTuner
if
use_DP
else
PBQPTuner
executor
=
Tuner
(
graph
,
{
"data"
:
dshape
},
records
,
target_op
,
target
)
executor
=
Tuner
(
graph
,
{
input_name
:
dshape
},
records
,
target_op
,
target
)
executor
.
benchmark_layout_transform
(
min_exec_num
=
2000
)
executor
.
run
()
executor
.
write_opt_sch2record_file
(
opt_sch_file
)
...
...
@@ -198,7 +202,7 @@ def tune_and_evaluate(tuning_opt):
ctx
=
tvm
.
cpu
()
data_tvm
=
tvm
.
nd
.
array
((
np
.
random
.
uniform
(
size
=
data_shape
))
.
astype
(
dtype
))
module
=
runtime
.
create
(
graph
,
lib
,
ctx
)
module
.
set_input
(
'data'
,
data_tvm
)
module
.
set_input
(
input_name
,
data_tvm
)
module
.
set_input
(
**
params
)
# evaluate
...
...
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