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
2ab0bfb5
Commit
2ab0bfb5
authored
Jul 15, 2017
by
Tianqi Chen
Committed by
GitHub
Jul 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RENAME] nvcc_compiler->nvcc, cc_compiler->cc, metal_compiler->xcode (#248)
parent
d3efd7fc
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
50 additions
and
44 deletions
+50
-44
docs/api/python/contrib.rst
+12
-8
python/tvm/contrib/cc.py
+0
-0
python/tvm/contrib/nvcc.py
+6
-11
python/tvm/contrib/rpc.py
+2
-2
python/tvm/contrib/xcode.py
+7
-4
python/tvm/module.py
+1
-1
src/common/socket.h
+6
-6
tests/python/unittest/test_codegen_cross_llvm.py
+1
-1
tests/python/unittest/test_module_load.py
+1
-1
tests/scripts/task_python_docs.sh
+2
-0
tests/scripts/task_python_integration.sh
+2
-0
tests/scripts/task_python_unittest.sh
+1
-1
topi/recipe/conv/depthwise_conv2d_map_test.py
+2
-2
topi/recipe/gemm/cuda_gemm_square.py
+2
-2
topi/recipe/rnn/lstm.py
+2
-2
topi/recipe/rnn/matexp.py
+2
-2
tutorials/python/get_started.py
+1
-1
No files found.
docs/api/python/contrib.rst
View file @
2ab0bfb5
...
...
@@ -2,18 +2,23 @@ Contrib APIs
------------
.. automodule:: tvm.contrib
tvm.contrib.nvcc_compiler
~~~~~~~~~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.nvcc_compiler
tvm.contrib.nvcc
~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.nvcc
:members:
tvm.contrib.cc
~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.cc
:members:
tvm.contrib.
cc_compiler
~~~~~~~~~~~~~~~~~
~~~~~~
.. automodule:: tvm.contrib.
cc_compiler
tvm.contrib.
xcode
~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.
xcode
:members:
tvm.contrib.rpc
~~~~~~~~~~~~~~~
~
~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.rpc
:members:
...
...
@@ -22,7 +27,6 @@ tvm.contrib.util
.. automodule:: tvm.contrib.util
:members:
tvm.contrib.cblas
~~~~~~~~~~~~~~~~~
.. automodule:: tvm.contrib.cblas
...
...
python/tvm/contrib/cc
_compiler
.py
→
python/tvm/contrib/cc.py
View file @
2ab0bfb5
File moved
python/tvm/contrib/nvcc
_compiler
.py
→
python/tvm/contrib/nvcc.py
View file @
2ab0bfb5
# pylint: disable=invalid-name
"""Utility to invoke nvcc compiler in the system"""
from
__future__
import
absolute_import
as
_abs
import
os
import
sys
import
tempfile
import
subprocess
from
.
import
util
def
compile_
source
(
code
,
target
=
"ptx"
,
arch
=
None
,
options
=
None
,
path_target
=
None
):
def
compile_
cuda
(
code
,
target
=
"ptx"
,
arch
=
None
,
options
=
None
,
path_target
=
None
):
"""Compile cuda code with NVCC from env.
Parameters
...
...
@@ -32,11 +31,11 @@ def compile_source(code, target="ptx", arch=None,
cubin : bytearray
The bytearray of the cubin
"""
temp
_dir
=
tempfile
.
mkdtemp
()
temp
=
util
.
tempdir
()
if
target
not
in
[
"cubin"
,
"ptx"
,
"fatbin"
]:
raise
ValueError
(
"target must be in cubin, ptx, fatbin"
)
temp_code
=
os
.
path
.
join
(
temp_dir
,
"my_kernel.cu"
)
temp_target
=
os
.
path
.
join
(
temp_dir
,
"my_kernel.
%
s"
%
target
)
temp_code
=
temp
.
relpath
(
"my_kernel.cu"
)
temp_target
=
temp
.
relpath
(
"my_kernel.
%
s"
%
target
)
with
open
(
temp_code
,
"w"
)
as
out_file
:
out_file
.
write
(
code
)
...
...
@@ -68,8 +67,4 @@ def compile_source(code, target="ptx", arch=None,
cubin
=
None
else
:
cubin
=
bytearray
(
open
(
file_target
,
"rb"
)
.
read
())
os
.
remove
(
temp_code
)
if
os
.
path
.
exists
(
temp_target
):
os
.
remove
(
temp_target
)
os
.
rmdir
(
temp_dir
)
return
cubin
python/tvm/contrib/rpc.py
View file @
2ab0bfb5
...
...
@@ -15,7 +15,7 @@ import socket
import
struct
import
logging
import
multiprocessing
from
.
import
util
,
cc
_compiler
from
.
import
util
,
cc
from
..module
import
load
as
_load_module
from
.._ffi.function
import
_init_api
,
register_func
from
.._ffi.ndarray
import
context
as
_context
...
...
@@ -39,7 +39,7 @@ def _server_env():
# Try create a shared library in remote
if
path
.
endswith
(
'.o'
):
logging
.
info
(
'Create shared library based on
%
s'
,
path
)
cc
_compiler
.
create_shared
(
path
+
'.so'
,
path
)
cc
.
create_shared
(
path
+
'.so'
,
path
)
path
+=
'.so'
m
=
_load_module
(
path
)
logging
.
info
(
"load_module
%
s"
,
path
)
...
...
python/tvm/contrib/
metal_compiler
.py
→
python/tvm/contrib/
xcode
.py
View file @
2ab0bfb5
# pylint: disable=invalid-name
"""Utility to invoke
metal compiler in the CLI system
"""
"""Utility to invoke
Xcode compiler toolchain
"""
from
__future__
import
absolute_import
as
_abs
import
sys
import
subprocess
from
.
import
util
def
compile_
source
(
code
,
path_target
=
None
):
def
compile_
metal
(
code
,
path_target
=
None
,
sdk
=
"macosx"
):
"""Compile metal with CLI tool from env.
Parameters
...
...
@@ -16,6 +16,9 @@ def compile_source(code, path_target=None):
path_target : str, optional
Output file.
sdk : str, optional
The target platform SDK.
Return
------
metallib : bytearray
...
...
@@ -30,9 +33,9 @@ def compile_source(code, path_target=None):
out_file
.
write
(
code
)
file_target
=
path_target
if
path_target
else
temp_target
cmd1
=
[
"xcrun"
,
"-sdk"
,
"macosx"
,
"metal"
,
"-O3"
]
cmd1
=
[
"xcrun"
,
"-sdk"
,
sdk
,
"metal"
,
"-O3"
]
cmd1
+=
[
temp_code
,
"-o"
,
temp_ir
]
cmd2
=
[
"xcrun"
,
"-sdk"
,
"macosx"
,
"metallib"
]
cmd2
=
[
"xcrun"
,
"-sdk"
,
sdk
,
"metallib"
]
cmd2
+=
[
temp_ir
,
"-o"
,
file_target
]
proc
=
subprocess
.
Popen
(
' '
.
join
(
cmd1
)
+
";"
+
' '
.
join
(
cmd2
),
...
...
python/tvm/module.py
View file @
2ab0bfb5
...
...
@@ -4,7 +4,7 @@ from __future__ import absolute_import as _abs
from
collections
import
namedtuple
from
._ffi.function
import
ModuleBase
,
_set_class_module
from
._ffi.function
import
_init_api
from
.contrib
import
cc
_compiler
as
_cc
,
util
as
_util
from
.contrib
import
cc
as
_cc
,
util
as
_util
ProfileResult
=
namedtuple
(
"ProfileResult"
,
[
"mean"
])
...
...
src/common/socket.h
View file @
2ab0bfb5
...
...
@@ -56,7 +56,7 @@ struct SockAddr {
}
/*!
* \brief set the address
* \param
url
the url of the address
* \param
host
the url of the address
* \param port the port of address
*/
void
Set
(
const
char
*
host
,
int
port
)
{
...
...
@@ -86,7 +86,7 @@ struct SockAddr {
&
buf
[
0
],
buf
.
length
());
#else
const
char
*
s
=
inet_ntop
(
AF_INET
,
&
addr
.
sin_addr
,
&
buf
[
0
],
buf
.
length
(
));
&
buf
[
0
],
static_cast
<
socklen_t
>
(
buf
.
length
()
));
#endif
CHECK
(
s
!=
nullptr
)
<<
"cannot decode address"
;
std
::
ostringstream
os
;
...
...
@@ -138,7 +138,7 @@ class Socket {
}
/*!
* \brief bind the socket to an address
* \param addr
* \param addr
The address to be binded
*/
void
Bind
(
const
SockAddr
&
addr
)
{
if
(
bind
(
sockfd
,
reinterpret_cast
<
const
sockaddr
*>
(
&
addr
.
addr
),
...
...
@@ -342,9 +342,9 @@ class TCPSocket : public Socket {
}
/*!
* \brief send data using the socket
* \param buf the pointer to the buffer
* \param buf
_
the pointer to the buffer
* \param len the size of the buffer
* \param flag
s
extra flags
* \param flag extra flags
* \return size of data actually sent
* return -1 if error occurs
*/
...
...
@@ -367,7 +367,7 @@ class TCPSocket : public Socket {
/*!
* \brief peform block write that will attempt to send all data out
* can still return smaller than request when error occurs
* \param buf the pointer to the buffer
* \param buf
_
the pointer to the buffer
* \param len the size of the buffer
* \return size of data actually sent
*/
...
...
tests/python/unittest/test_codegen_cross_llvm.py
View file @
2ab0bfb5
...
...
@@ -2,7 +2,7 @@
import
tvm
import
os
import
struct
from
tvm.contrib
import
util
,
cc
_compiler
as
cc
,
rpc
from
tvm.contrib
import
util
,
cc
,
rpc
import
numpy
as
np
def
test_llvm_add_pipeline
():
...
...
tests/python/unittest/test_module_load.py
View file @
2ab0bfb5
import
tvm
from
tvm.contrib
import
cc
_compiler
as
cc
,
util
from
tvm.contrib
import
cc
,
util
import
ctypes
import
os
import
numpy
as
np
...
...
tests/scripts/task_python_docs.sh
View file @
2ab0bfb5
...
...
@@ -8,6 +8,8 @@ make doc
jsdoc web/tvm_runtime.js web/README.md
||
exit
-1
mv out docs/_build/html/jsdoc
||
exit
-1
rm
-rf
python/tvm/
*
.pyc python/tvm/
*
/
*
.pyc
cd
docs
PYTHONPATH
=
../python make html
||
exit
-1
cd
_build/html
...
...
tests/scripts/task_python_integration.sh
View file @
2ab0bfb5
...
...
@@ -3,6 +3,8 @@ export PYTHONPATH=python:apps/extension/python
export
PYTHONPATH
=
${
PYTHONPATH
}
:apps/graph_executor/python:apps/graph_executor/nnvm/python
export
LD_LIBRARY_PATH
=
lib:
${
LD_LIBRARY_PATH
}
rm
-rf
python/tvm/
*
.pyc python/tvm/
*
/
*
.pyc
# Test TVM
make cython
||
exit
-1
...
...
tests/scripts/task_python_unittest.sh
View file @
2ab0bfb5
...
...
@@ -2,7 +2,7 @@
export
PYTHONPATH
=
python
rm
-rf
python/tvm/
*
.pyc
rm
-rf
python/tvm/
*
.pyc
python/tvm/
*
/
*
.pyc
TVM_FFI
=
ctypes python
-m
nose
-v
tests/python/unittest
||
exit
-1
TVM_FFI
=
ctypes python3
-m
nose
-v
tests/python/unittest
||
exit
-1
...
...
topi/recipe/conv/depthwise_conv2d_map_test.py
View file @
2ab0bfb5
...
...
@@ -2,7 +2,7 @@ import os
import
tvm
import
numpy
as
np
from
scipy
import
signal
from
tvm.contrib
import
nvcc
_compiler
from
tvm.contrib
import
nvcc
import
topi
from
topi.nn.util
import
get_const_tuple
...
...
@@ -13,7 +13,7 @@ USE_MANUAL_CODE = False
@tvm.register_func
def
tvm_callback_cuda_compile
(
code
):
ptx
=
nvcc
_compiler
.
compile_source
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
ptx
=
nvcc
.
compile_cuda
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
return
ptx
def
write_code
(
code
,
fname
):
...
...
topi/recipe/gemm/cuda_gemm_square.py
View file @
2ab0bfb5
"""Example code to do square matrix multiplication."""
import
tvm
import
os
from
tvm.contrib
import
nvcc
_compiler
from
tvm.contrib
import
nvcc
import
numpy
as
np
TASK
=
"gemm"
...
...
@@ -9,7 +9,7 @@ USE_MANUAL_CODE = False
@tvm.register_func
def
tvm_callback_cuda_compile
(
code
):
ptx
=
nvcc
_compiler
.
compile_source
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
ptx
=
nvcc
.
compile_cuda
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
return
ptx
def
write_code
(
code
,
fname
):
...
...
topi/recipe/rnn/lstm.py
View file @
2ab0bfb5
...
...
@@ -3,7 +3,7 @@ import tvm
import
time
import
os
import
argparse
from
tvm.contrib
import
nvcc
_compiler
from
tvm.contrib
import
nvcc
import
numpy
as
np
# Quick knobs
...
...
@@ -17,7 +17,7 @@ UNROLL_WLOAD = True
@tvm.register_func
def
tvm_callback_cuda_compile
(
code
):
"""Use nvcc compiler for better perf."""
ptx
=
nvcc
_compiler
.
compile_source
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
ptx
=
nvcc
.
compile_cuda
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
return
ptx
def
write_code
(
code
,
fname
):
...
...
topi/recipe/rnn/matexp.py
View file @
2ab0bfb5
...
...
@@ -11,7 +11,7 @@ import tvm
import
time
import
os
import
argparse
from
tvm.contrib
import
nvcc
_compiler
from
tvm.contrib
import
nvcc
import
numpy
as
np
# Quick knobs
...
...
@@ -24,7 +24,7 @@ SKIP_CHECK = False
@tvm.register_func
def
tvm_callback_cuda_compile
(
code
):
"""Use nvcc compiler for better perf."""
ptx
=
nvcc
_compiler
.
compile_source
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
ptx
=
nvcc
.
compile_cuda
(
code
,
target
=
"ptx"
,
options
=
[
"-arch=sm_52"
])
return
ptx
def
write_code
(
code
,
fname
):
...
...
tutorials/python/get_started.py
View file @
2ab0bfb5
...
...
@@ -175,7 +175,7 @@ print(dev_module.get_source())
# - Then it saves the device module into a ptx file.
# - cc.create_shared calls a env compiler(gcc) to create a shared library
#
from
tvm.contrib
import
cc
_compiler
as
cc
from
tvm.contrib
import
cc
from
tvm.contrib
import
util
temp
=
util
.
tempdir
()
...
...
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