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
8902ae7b
Commit
8902ae7b
authored
Jan 24, 2018
by
Mu Li
Committed by
Tianqi Chen
Jan 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update cross_compilation_and_rpc.py (#816)
parent
37734045
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
9 deletions
+31
-9
tutorials/deployment/cross_compilation_and_rpc.py
+31
-9
No files found.
tutorials/deployment/cross_compilation_and_rpc.py
View file @
8902ae7b
...
...
@@ -14,11 +14,6 @@ the device in order to save time and space.
In this tutorial, I will take Raspberry Pi as our target platform
for example.
"""
from
__future__
import
absolute_import
,
print_function
import
tvm
import
numpy
as
np
from
tvm.contrib
import
rpc
,
util
######################################################################
# Build TVM Runtime on Device
...
...
@@ -27,6 +22,12 @@ from tvm.contrib import rpc, util
# There're some prerequisites: similar as compiling TVM on your
# local machine, we need build runtime on remote device.
#
# .. note::
#
# All instructions in both this section and next section should be
# executed on the target device, e.g. Raspberry Pi. And we assume it
# has Linux running.
#
# To get started, clone tvm repo from github. It is important to clone
# the submodules along, with --recursive option (Assuming you are in
# your home directory):
...
...
@@ -106,8 +107,19 @@ server = rpc.Server(host='0.0.0.0', port=9090, use_popen=True)
######################################################################
# Declare and Cross Compile Kernel on Local Machine
# -------------------------------------------------
# Here we will declare a simple kernel with TVM on the local machine:
#
# .. note::
#
# Now we back to the local machine, which has a full TVM installed.
#
# Here we will declare a simple kernel with TVM on the local machine:
from
__future__
import
absolute_import
,
print_function
import
tvm
import
numpy
as
np
from
tvm.contrib
import
rpc
,
util
n
=
tvm
.
convert
(
1024
)
A
=
tvm
.
placeholder
((
n
,),
name
=
'A'
)
B
=
tvm
.
compute
(
A
.
shape
,
lambda
*
i
:
A
(
*
i
)
+
1.0
,
name
=
'B'
)
...
...
@@ -136,7 +148,8 @@ f.save(path)
# Pi. Here we use :code:`'llvm'` directly to make the tutorial runable.
#
# Usually, you can query the target by execute :code:`gcc -v` on your
# device, although it may be still a loose configuration.
# device, and look for the line starting with :code:`Target:`
# (Though it may be still a loose configuration.)
#
# Besides :code:`-target`, you can also set other compilation options
# like:
...
...
@@ -171,9 +184,15 @@ f.save(path)
# Run CPU Kernel Remotely by RPC
# ------------------------------
# Here we will show you how to run the kernel on the remote device:
#
# .. note::
# In order to have this tutorial runs locally to build the nice HTML, we
# start a RPC server on the local machine. You can ignore it if you already
# started the server on the target device. And then change host IP properly.
# replace host with the ip address of your device
host
=
'0.0.0.0'
# Can be ignored if you already started the RPC server
server
=
rpc
.
Server
(
host
=
'0.0.0.0'
,
port
=
9090
,
use_popen
=
True
)
host
=
'0.0.0.0'
# Change to your target device IP
port
=
9090
# connect the remote device
remote
=
rpc
.
connect
(
host
,
port
)
...
...
@@ -213,9 +232,12 @@ print('%g secs/op' % cost)
# on remote compiler to re-link them.
#
# .. note::
#
# Raspberry Pi does not support OpenCL, the following code is tested on
# Firefly-RK3399. The target_host should be 'llvm -target=aarch64-linux-gnu'.
# But here we set 'llvm' to enable this tutorial to run locally.
#
# Also we need to build the runtime with the flag `USE_OPENCL=1`.
# build kernel (different from cpu, we need bind axis for OpenCL)
s
=
tvm
.
create_schedule
(
B
.
op
)
...
...
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