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
de027d94
Commit
de027d94
authored
Sep 26, 2017
by
Leyuan Wang
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge with pull request #44 (#46)
* resnet example merged to imagenet * merge with master
parent
4f664f5b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
9 deletions
+16
-9
nnvm/python/nnvm/testing/resnet.py
+10
-6
nnvm/tutorials/imagenet_inference_gpu.py
+6
-3
No files found.
nnvm/python/nnvm/testing/resnet.py
View file @
de027d94
...
@@ -40,7 +40,8 @@ def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck=True):
...
@@ -40,7 +40,8 @@ def residual_unit(data, num_filter, stride, dim_match, name, bottle_neck=True):
stride : tuple
stride : tuple
Stride used in convolution
Stride used in convolution
dim_match : Boolean
dim_match : Boolean
True means channel number between input and output is the same, otherwise means differ
True means channel number between input and output is the same,
otherwise means differ
name : str
name : str
Base name of the operators
Base name of the operators
"""
"""
...
@@ -146,7 +147,7 @@ def resnet(units, num_stages, filter_list, num_classes, image_shape,
...
@@ -146,7 +147,7 @@ def resnet(units, num_stages, filter_list, num_classes, image_shape,
fc1
=
sym
.
cast
(
data
=
fc1
,
dtype
=
np
.
float32
)
fc1
=
sym
.
cast
(
data
=
fc1
,
dtype
=
np
.
float32
)
return
sym
.
softmax
(
data
=
fc1
,
name
=
'softmax'
)
return
sym
.
softmax
(
data
=
fc1
,
name
=
'softmax'
)
def
get_symbol
(
num_classes
,
num_layers
=
50
,
image_shape
=
(
3
,
224
,
224
),
dtype
=
'float32'
):
def
get_symbol
(
num_classes
,
num_layers
=
50
,
image_shape
=
(
3
,
224
,
224
),
dtype
=
'float32'
,
**
kwargs
):
"""
"""
Adapted from https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py
Adapted from https://github.com/tornadomeet/ResNet/blob/master/train_resnet.py
Original author Wei Wu
Original author Wei Wu
...
@@ -198,8 +199,8 @@ def get_symbol(num_classes, num_layers=50, image_shape=(3, 224, 224), dtype='flo
...
@@ -198,8 +199,8 @@ def get_symbol(num_classes, num_layers=50, image_shape=(3, 224, 224), dtype='flo
bottle_neck
=
bottle_neck
,
bottle_neck
=
bottle_neck
,
dtype
=
dtype
)
dtype
=
dtype
)
def
get_workload
(
batch_size
,
num_classes
=
1000
,
image_shape
=
(
3
,
224
,
224
)
,
def
get_workload
(
batch_size
=
1
,
num_classes
=
1000
,
num_layers
=
18
,
dtype
=
"float32"
,
**
kwargs
):
image_shape
=
(
3
,
224
,
224
),
dtype
=
"float32"
,
**
kwargs
):
"""Get benchmark workload for resnet
"""Get benchmark workload for resnet
Parameters
Parameters
...
@@ -210,6 +211,9 @@ def get_workload(batch_size, num_classes=1000, image_shape=(3, 224, 224),
...
@@ -210,6 +211,9 @@ def get_workload(batch_size, num_classes=1000, image_shape=(3, 224, 224),
num_classes : int, optional
num_classes : int, optional
Number of claseses
Number of claseses
num_layers : int, optional
Number of layers
image_shape : tuple, optional
image_shape : tuple, optional
The input image shape
The input image shape
...
@@ -227,6 +231,6 @@ def get_workload(batch_size, num_classes=1000, image_shape=(3, 224, 224),
...
@@ -227,6 +231,6 @@ def get_workload(batch_size, num_classes=1000, image_shape=(3, 224, 224),
params : dict of str to NDArray
params : dict of str to NDArray
The parameters.
The parameters.
"""
"""
net
=
get_symbol
(
num_classes
=
num_classes
,
image_shape
=
image_shape
,
net
=
get_symbol
(
num_classes
=
num_classes
,
num_layers
=
num_layers
,
dtype
=
dtype
,
**
kwargs
)
image_shape
=
image_shape
,
dtype
=
dtype
,
**
kwargs
)
return
create_workload
(
net
,
batch_size
,
image_shape
,
dtype
)
return
create_workload
(
net
,
batch_size
,
image_shape
,
dtype
)
nnvm/tutorials/
mobil
enet_inference_gpu.py
→
nnvm/tutorials/
imag
enet_inference_gpu.py
View file @
de027d94
"""
"""
Compile
Mobil
eNet Inference on GPU
Compile
Imag
eNet Inference on GPU
==================================
==================================
**Author**: `Yuwei Hu <https://huyuwei.github.io/>`_
**Author**: `Yuwei Hu <https://huyuwei.github.io/>`_
This is an example of using NNVM to compile MobileNet model and deploy its inference on GPU.
This is an example of using NNVM to compile MobileNet
/ResNet
model and deploy its inference on GPU.
To begin with, we import nnvm(for compilation) and TVM(for deployment).
To begin with, we import nnvm(for compilation) and TVM(for deployment).
"""
"""
...
@@ -39,7 +39,7 @@ def tvm_callback_cuda_compile(code):
...
@@ -39,7 +39,7 @@ def tvm_callback_cuda_compile(code):
# .. note::
# .. note::
#
#
# In a typical workflow, we can get this pair from :any:`nnvm.frontend`
# In a typical workflow, we can get this pair from :any:`nnvm.frontend`
#
#
Example: /nnvm-top/tests/python/frontend/mxnet/test_forward.py
target
=
"cuda"
target
=
"cuda"
ctx
=
tvm
.
gpu
(
0
)
ctx
=
tvm
.
gpu
(
0
)
batch_size
=
1
batch_size
=
1
...
@@ -47,6 +47,9 @@ num_classes = 1000
...
@@ -47,6 +47,9 @@ num_classes = 1000
image_shape
=
(
3
,
224
,
224
)
image_shape
=
(
3
,
224
,
224
)
data_shape
=
(
batch_size
,)
+
image_shape
data_shape
=
(
batch_size
,)
+
image_shape
out_shape
=
(
batch_size
,
num_classes
)
out_shape
=
(
batch_size
,
num_classes
)
# To use ResNet to do inference, run the following instead
#net, params = nnvm.testing.resnet.get_workload(
# batch_size=1, image_shape=image_shape)
net
,
params
=
nnvm
.
testing
.
mobilenet
.
get_workload
(
net
,
params
=
nnvm
.
testing
.
mobilenet
.
get_workload
(
batch_size
=
1
,
image_shape
=
image_shape
)
batch_size
=
1
,
image_shape
=
image_shape
)
...
...
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