Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tvm
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
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cld
ml
tvm
Commits
09215019
Commit
09215019
authored
7 years ago
by
Joshua Z. Zhang
Committed by
Tianqi Chen
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[TUTORIAL] use resnet v2 (#51)
* use resnet v2 * fix
parent
120753d4
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
nnvm/tutorials/from_mxnet.py
+5
-5
5 additions, 5 deletions
nnvm/tutorials/from_mxnet.py
with
5 additions
and
5 deletions
nnvm/tutorials/from_mxnet.py
+
5
−
5
View file @
09215019
...
...
@@ -28,7 +28,7 @@ from mxnet.gluon.model_zoo.vision import get_model
from
mxnet.gluon.utils
import
download
import
Image
from
matplotlib
import
pyplot
as
plt
block
=
get_model
(
'
resnet18_v
1
'
,
pretrained
=
True
)
block
=
get_model
(
'
resnet18_v
2
'
,
pretrained
=
True
)
img_name
=
'
cat.jpg
'
synset_url
=
''
.
join
([
'
https://gist.githubusercontent.com/zhreshold/
'
,
'
4d0b62f3d01426887599d4f7ede23ee5/raw/
'
,
...
...
@@ -85,7 +85,7 @@ m.set_input(**params)
m
.
run
()
# get outputs
tvm_output
=
m
.
get_output
(
0
,
tvm
.
nd
.
empty
((
1000
,),
dtype
))
top1
=
np
.
argmax
(
tvm_output
)
top1
=
np
.
argmax
(
tvm_output
.
asnumpy
()
)
print
(
'
TVM prediction top-1:
'
,
top1
,
synset
[
top1
])
######################################################################
...
...
@@ -103,12 +103,12 @@ def block2symbol(block):
return
sym
,
args
,
auxs
mx_sym
,
args
,
auxs
=
block2symbol
(
block
)
# usually we would save/load it as checkpoint
mx
.
model
.
save_checkpoint
(
'
resnet18_v
1
'
,
0
,
mx_sym
,
args
,
auxs
)
# there are 'resnet18_v
1
-0000.params' and 'resnet18_v
1
-symbol.json' on disk
mx
.
model
.
save_checkpoint
(
'
resnet18_v
2
'
,
0
,
mx_sym
,
args
,
auxs
)
# there are 'resnet18_v
2
-0000.params' and 'resnet18_v
2
-symbol.json' on disk
######################################################################
# for a normal mxnet model, we start from here
mx_sym
,
args
,
auxs
=
mx
.
model
.
load_checkpoint
(
'
resnet18_v
1
'
,
0
)
mx_sym
,
args
,
auxs
=
mx
.
model
.
load_checkpoint
(
'
resnet18_v
2
'
,
0
)
# now we use the same API to get NNVM compatible symbol
nnvm_sym
,
nnvm_params
=
nnvm
.
frontend
.
from_mxnet
(
mx_sym
,
args
,
auxs
)
# repeat the same steps to run this model using TVM
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