Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay][RFC] Relay IR Text Format #1781

Merged
merged 64 commits into from
Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
4f37853
squashed first 30 commits
joshpoll Oct 8, 2018
4717f68
use multiply, divide, and negative
joshpoll Oct 8, 2018
a38b9bf
towards working defn + refactoring
joshpoll Oct 8, 2018
07ec0ed
comment out failing test
joshpoll Oct 8, 2018
c6c9f09
ifelse and bool_lit
joshpoll Oct 9, 2018
00e79e0
funcType -> callType
joshpoll Oct 9, 2018
dfd2954
scientific notation tests
joshpoll Oct 9, 2018
959e8ab
parens and op associativity
joshpoll Oct 9, 2018
efe648a
use alpha_equal for tests
joshpoll Oct 9, 2018
4438d44
call. func+defn refactoring. work towards identtype and calltype
joshpoll Oct 9, 2018
b8bb3a7
identType, callType, tupleType, comment out unimplemented portions of…
joshpoll Oct 10, 2018
d4fb940
function annotations
joshpoll Oct 10, 2018
e6e2bf8
funcType and syntax changes (in particular => to ->)
joshpoll Oct 11, 2018
390dbea
attempt at adding antlr4 to cmake. remove outdated grammar rules. upd…
joshpoll Oct 13, 2018
2174b6a
add antlr to cmake. add new unused grammar rules. refactoring
joshpoll Oct 14, 2018
8a9c41e
fix alpha eq bug and change tests to use alpha eq. test refactoring
joshpoll Oct 14, 2018
41bb1ed
switch parser to use None instead of IncompleteType. revise alpha_eq …
joshpoll Oct 15, 2018
20f1add
refactor for new commits
joshpoll Oct 16, 2018
0657f4c
restore tests
joshpoll Oct 16, 2018
ba61579
restore def test
joshpoll Oct 16, 2018
445a622
python linting
joshpoll Oct 16, 2018
080df42
change sequence parsing
joshpoll Oct 18, 2018
a12bc17
remove compiler options
joshpoll Oct 18, 2018
9a34108
attempt at tensor + shape types
joshpoll Oct 19, 2018
a20a68d
op test
joshpoll Oct 19, 2018
32f644b
tensor type
joshpoll Oct 19, 2018
7742e0c
fix some rebase issues
joshpoll Oct 19, 2018
720af91
account for change in relay.Function interface and use relay.const
joshpoll Oct 19, 2018
1069677
remove pretty printer test file
joshpoll Oct 19, 2018
703673c
-> only when return type is present. fn for function types
joshpoll Oct 21, 2018
2a1de38
semver
joshpoll Oct 22, 2018
becedbf
add python type checking to git ignore
joshpoll Oct 22, 2018
955fc4e
make bools and builtin types more python-esque. realign antlr tags
joshpoll Oct 22, 2018
5de44c7
rm unused code
joshpoll Oct 23, 2018
8715a7e
linting
joshpoll Oct 23, 2018
4301600
revert nullable alpha_equal changes
joshpoll Oct 23, 2018
c1db228
cmake config
joshpoll Oct 25, 2018
f6991fc
delete alpha_eq
joshpoll Oct 25, 2018
96960bd
use scalar_type
joshpoll Oct 26, 2018
d640525
expose parse and parse_file via __init__.py
joshpoll Nov 1, 2018
e33b425
towards parser script tests
joshpoll Nov 1, 2018
7d956fb
complete parser testing compatibility and expose fromtext
joshpoll Nov 2, 2018
a396cf7
fix bad imports
joshpoll Nov 2, 2018
e04dfa5
ImportError -> Exception
joshpoll Nov 2, 2018
3fd20b1
linting
joshpoll Nov 2, 2018
9f03684
linting
joshpoll Nov 2, 2018
98e44c5
linting
joshpoll Nov 2, 2018
ac74b91
ci bump
joshpoll Nov 2, 2018
fe8a7a6
exit earlier
joshpoll Nov 2, 2018
bac7c19
dependencies
joshpoll Nov 2, 2018
fcd220b
delete separate script
joshpoll Nov 2, 2018
0cf7594
failing test. should fail ci
joshpoll Nov 2, 2018
30bbbfc
simplify failing test. rework import
joshpoll Nov 2, 2018
4eaca59
switch USE_ANTLR from cpu to gpu
joshpoll Nov 2, 2018
3199d1e
rebase
joshpoll Nov 20, 2018
081a907
fix ci (please)
joshpoll Nov 28, 2018
f837861
source /etc/profile to add JAVA_HOME
joshpoll Nov 30, 2018
7eefbf3
revert install_java change. source /etc/profile during make function
joshpoll Nov 30, 2018
f3abc5d
enable antlr on gpu
joshpoll Nov 30, 2018
3e2244f
trigger parser tests
joshpoll Nov 30, 2018
ce72502
revert Dockerfile to master. remove parser tests from this pr
joshpoll Dec 1, 2018
f092434
revert source
joshpoll Dec 1, 2018
5653528
use ENV
joshpoll Dec 1, 2018
533972b
modify how ANTLR runs in cmake
joshpoll Dec 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,7 @@ tvm_t.*

# patch sentinel
patched.txt

# Python type checking
.mypy_cache/
.pyre/
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ tvm_option(USE_ROCBLAS "Build with ROCM:RoCBLAS" OFF)
tvm_option(USE_SORT "Build with sort support" OFF)
tvm_option(USE_NNPACK "Build with nnpack support" OFF)
tvm_option(USE_RANDOM "Build with random support" OFF)
tvm_option(USE_ANTLR "Build with ANTLR for Relay parsing" OFF)

# include directories
include_directories("include")
Expand Down Expand Up @@ -183,6 +184,7 @@ include(cmake/modules/Metal.cmake)
include(cmake/modules/ROCM.cmake)
include(cmake/modules/SGX.cmake)
include(cmake/modules/LLVM.cmake)
include(cmake/modules/ANTLR.cmake)
include(cmake/modules/contrib/BLAS.cmake)
include(cmake/modules/contrib/Random.cmake)
include(cmake/modules/contrib/Sort.cmake)
Expand Down
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ stage('Build') {
echo set\\(USE_GRAPH_RUNTIME ON\\) >> config.cmake
echo set\\(USE_STACKVM_RUNTIME ON\\) >> config.cmake
echo set\\(USE_GRAPH_RUNTIME_DEBUG ON\\) >> config.cmake
echo set\\(USE_ANTLR ON\\) >> config.cmake
echo set\\(USE_BLAS openblas\\) >> config.cmake
echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake
echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake
Expand Down Expand Up @@ -133,6 +134,7 @@ stage('Build') {
echo set\\(USE_LLVM llvm-config-4.0\\) >> config.cmake
echo set\\(USE_NNPACK ON\\) >> config.cmake
echo set\\(NNPACK_PATH /NNPACK/build/\\) >> config.cmake
echo set\\(USE_ANTLR ON\\) >> config.cmake
echo set\\(CMAKE_CXX_COMPILER g++\\) >> config.cmake
echo set\\(CMAKE_CXX_FLAGS -Werror\\) >> config.cmake
"""
Expand Down
3 changes: 3 additions & 0 deletions cmake/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ set(USE_ROCBLAS OFF)

# Whether use contrib sort
set(USE_SORT OFF)

# Build ANTLR parser for Relay text format
set(USE_ANTLR OFF)
28 changes: 28 additions & 0 deletions cmake/modules/ANTLR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
if(USE_ANTLR)
if(EXISTS /usr/local/lib/antlr-4.7.1-complete.jar)
set(ANTLR4 "/usr/local/lib/antlr-4.7.1-complete.jar")

set(RELAY_PARSER_DIR
${CMAKE_CURRENT_SOURCE_DIR}/python/tvm/relay/grammar)

set(RELAY_PARSER
${RELAY_PARSER_DIR}/py2/RelayVisitor.py
${RELAY_PARSER_DIR}/py2/RelayParser.py
${RELAY_PARSER_DIR}/py2/RelayLexer.py

${RELAY_PARSER_DIR}/py3/RelayVisitor.py
${RELAY_PARSER_DIR}/py3/RelayParser.py
${RELAY_PARSER_DIR}/py3/RelayLexer.py)

# Generate ANTLR grammar for parsing.
add_custom_command(OUTPUT ${RELAY_PARSER}
COMMAND $ENV{JAVA_HOME}/bin/java -jar ${ANTLR4} -visitor -no-listener -Dlanguage=Python2 ${RELAY_PARSER_DIR}/Relay.g4 -o ${RELAY_PARSER_DIR}/py2
COMMAND $ENV{JAVA_HOME}/bin/java -jar ${ANTLR4} -visitor -no-listener -Dlanguage=Python3 ${RELAY_PARSER_DIR}/Relay.g4 -o ${RELAY_PARSER_DIR}/py3
DEPENDS ${RELAY_PARSER_DIR}/Relay.g4
WORKING_DIRECTORY ${RELAY_PARSER_DIR})

add_custom_target(relay_parser ALL DEPENDS ${RELAY_PARSER})
else()
message(FATAL_ERROR "Can't find ANTLR4!")
endif()
endif(USE_ANTLR)
7 changes: 0 additions & 7 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,3 @@ COPY install/ubuntu_install_nnpack.sh /install/ubuntu_install_nnpack.sh
RUN bash /install/ubuntu_install_nnpack.sh

ENV PATH $PATH:$CARGO_HOME/bin:/usr/lib/go-1.10/bin

# ANTLR deps
COPY install/ubuntu_install_java.sh /install/ubuntu_install_java.sh
RUN bash /install/ubuntu_install_java.sh

COPY install/ubuntu_install_antlr.sh /install/ubuntu_install_antlr.sh
RUN bash /install/ubuntu_install_antlr.sh
2 changes: 0 additions & 2 deletions docker/install/ubuntu_install_antlr.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cd /usr/local/lib
wget https://www.antlr.org/download/antlr-4.7.1-complete.jar
cd -

alias antlr4='java -jar /usr/local/lib/antlr-4.7.1-complete.jar'
5 changes: 4 additions & 1 deletion python/tvm/relay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from . import module
from . import ir_pass
from .build_module import build, build_config, create_executor
from . import parser

# Root operators
from .op import Op
Expand Down Expand Up @@ -52,7 +53,6 @@
If = expr.If
TupleGetItem = expr.TupleGetItem


# helper functions
var = expr.var
const = expr.const
Expand All @@ -63,3 +63,6 @@
def _debug(*args):
import pdb
pdb.set_trace()

# Parser
fromtext = parser.fromtext
Loading