Commit b05dc12f by 雾雨魔理沙 Committed by Yizhi Liu

[Relay][Parser] simplify build script, remove python 2 support (#3419)

* simplify build script, remove python 2 support

* remove py2 file

* update py3
parent 1e9d014b
...@@ -16,44 +16,19 @@ ...@@ -16,44 +16,19 @@
# under the License. # under the License.
if(USE_ANTLR) if(USE_ANTLR)
file(GLOB_RECURSE ANTLR4 set(RELAY_PARSER_DIR
/usr/local/lib/antlr-*-complete.jar ${CMAKE_CURRENT_SOURCE_DIR}/python/tvm/relay/grammar)
/usr/local/Cellar/*antlr-*-complete.jar)
if(DEFINED ANTLR4) set(RELAY_PARSER
# Get the first element of the list of antlr jars. ${RELAY_PARSER_DIR}/py3/RelayVisitor.py
# Sort and reverse the list so the item selected is the highest ${RELAY_PARSER_DIR}/py3/RelayParser.py
# version in lib or else in Cellar if no lib installation exists. ${RELAY_PARSER_DIR}/py3/RelayLexer.py)
list(SORT ANTLR4)
list(REVERSE ANTLR4)
list(GET ANTLR4 0 ANTLR4)
set(RELAY_PARSER_DIR
${CMAKE_CURRENT_SOURCE_DIR}/python/tvm/relay/grammar)
set(RELAY_PARSER # Generate ANTLR grammar for parsing.
${RELAY_PARSER_DIR}/py2/RelayVisitor.py add_custom_command(OUTPUT ${RELAY_PARSER}
${RELAY_PARSER_DIR}/py2/RelayParser.py COMMAND antlr4 -visitor -no-listener -Dlanguage=Python3 ${RELAY_PARSER_DIR}/Relay.g4 -o ${RELAY_PARSER_DIR}/py3
${RELAY_PARSER_DIR}/py2/RelayLexer.py DEPENDS ${RELAY_PARSER_DIR}/Relay.g4
WORKING_DIRECTORY ${RELAY_PARSER_DIR})
${RELAY_PARSER_DIR}/py3/RelayVisitor.py add_custom_target(relay_parser ALL DEPENDS ${RELAY_PARSER})
${RELAY_PARSER_DIR}/py3/RelayParser.py
${RELAY_PARSER_DIR}/py3/RelayLexer.py)
set(JAVA_HOME $ENV{JAVA_HOME})
if (NOT DEFINED JAVA_HOME)
# Hack to get system to search for Java itself.
set(JAVA_HOME "/usr")
endif()
# Generate ANTLR grammar for parsing.
add_custom_command(OUTPUT ${RELAY_PARSER}
COMMAND ${JAVA_HOME}/bin/java -jar ${ANTLR4} -visitor -no-listener -Dlanguage=Python2 ${RELAY_PARSER_DIR}/Relay.g4 -o ${RELAY_PARSER_DIR}/py2
COMMAND ${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: ANTLR4=" ${ANTLR4})
endif()
endif(USE_ANTLR) endif(USE_ANTLR)
...@@ -43,14 +43,9 @@ class ParseError(Exception): ...@@ -43,14 +43,9 @@ class ParseError(Exception):
PYTHON_VERSION = sys.version_info.major PYTHON_VERSION = sys.version_info.major
try: try:
if PYTHON_VERSION == 2: from .grammar.py3.RelayVisitor import RelayVisitor
from .grammar.py2.RelayVisitor import RelayVisitor from .grammar.py3.RelayParser import RelayParser
from .grammar.py2.RelayParser import RelayParser from .grammar.py3.RelayLexer import RelayLexer
from .grammar.py2.RelayLexer import RelayLexer
else:
from .grammar.py3.RelayVisitor import RelayVisitor
from .grammar.py3.RelayParser import RelayParser
from .grammar.py3.RelayLexer import RelayLexer
except ImportError: except ImportError:
raise ParseError("Couldn't find ANTLR parser. Try building with USE_ANTLR=ON.") raise ParseError("Couldn't find ANTLR parser. Try building with USE_ANTLR=ON.")
......
Relay* binary
Relay* linguist-generated=true
Relay* linguist-detectable=false
\ No newline at end of file
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
SEMVER=19
WS=20
LINE_COMMENT=21
COMMENT=22
MUL=23
DIV=24
ADD=25
SUB=26
LT=27
GT=28
LE=29
GE=30
EQ=31
NE=32
GLOBAL_VAR=33
LOCAL_VAR=34
GRAPH_VAR=35
MUT=36
BOOL_LIT=37
FLOAT=38
NAT=39
CNAME=40
'('=1
')'=2
','=3
'['=4
']'=5
'if'=6
'else'=7
'let'=8
'='=9
';'=10
'{'=11
'}'=12
'fn'=13
'->'=14
'def'=15
':'=16
'Tensor'=17
'_'=18
'v0.0.2'=19
'*'=23
'/'=24
'+'=25
'-'=26
'<'=27
'>'=28
'<='=29
'>='=30
'=='=31
'!='=32
'mut'=36
token literal names:
null
'('
')'
','
'['
']'
'if'
'else'
'let'
'='
';'
'{'
'}'
'fn'
'->'
'def'
':'
'Tensor'
'_'
'v0.0.2'
null
null
null
'*'
'/'
'+'
'-'
'<'
'>'
'<='
'>='
'=='
'!='
null
null
null
'mut'
null
null
null
null
token symbolic names:
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
SEMVER
WS
LINE_COMMENT
COMMENT
MUL
DIV
ADD
SUB
LT
GT
LE
GE
EQ
NE
GLOBAL_VAR
LOCAL_VAR
GRAPH_VAR
MUT
BOOL_LIT
FLOAT
NAT
CNAME
rule names:
T__0
T__1
T__2
T__3
T__4
T__5
T__6
T__7
T__8
T__9
T__10
T__11
T__12
T__13
T__14
T__15
T__16
T__17
SEMVER
WS
LINE_COMMENT
COMMENT
MUL
DIV
ADD
SUB
LT
GT
LE
GE
EQ
NE
GLOBAL_VAR
LOCAL_VAR
GRAPH_VAR
MUT
BOOL_LIT
FLOAT
NAT
EXP
CNAME
LETTER
DIGIT
channel names:
DEFAULT_TOKEN_CHANNEL
HIDDEN
mode names:
DEFAULT_MODE
atn:
[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 42, 267, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 6, 21, 149, 10, 21, 13, 21, 14, 21, 150, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 7, 22, 159, 10, 22, 12, 22, 14, 22, 162, 11, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 7, 23, 172, 10, 23, 12, 23, 14, 23, 175, 11, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 25, 3, 25, 3, 26, 3, 26, 3, 27, 3, 27, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 5, 38, 228, 10, 38, 3, 39, 3, 39, 3, 39, 3, 39, 5, 39, 234, 10, 39, 3, 39, 3, 39, 3, 39, 5, 39, 239, 10, 39, 3, 40, 6, 40, 242, 10, 40, 13, 40, 14, 40, 243, 3, 41, 3, 41, 5, 41, 248, 10, 41, 3, 41, 3, 41, 3, 42, 3, 42, 5, 42, 254, 10, 42, 3, 42, 3, 42, 3, 42, 7, 42, 259, 10, 42, 12, 42, 14, 42, 262, 11, 42, 3, 43, 3, 43, 3, 44, 3, 44, 4, 160, 173, 2, 45, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 2, 83, 42, 85, 2, 87, 2, 3, 2, 7, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 4, 2, 67, 92, 99, 124, 3, 2, 50, 59, 2, 275, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 3, 89, 3, 2, 2, 2, 5, 91, 3, 2, 2, 2, 7, 93, 3, 2, 2, 2, 9, 95, 3, 2, 2, 2, 11, 97, 3, 2, 2, 2, 13, 99, 3, 2, 2, 2, 15, 102, 3, 2, 2, 2, 17, 107, 3, 2, 2, 2, 19, 111, 3, 2, 2, 2, 21, 113, 3, 2, 2, 2, 23, 115, 3, 2, 2, 2, 25, 117, 3, 2, 2, 2, 27, 119, 3, 2, 2, 2, 29, 122, 3, 2, 2, 2, 31, 125, 3, 2, 2, 2, 33, 129, 3, 2, 2, 2, 35, 131, 3, 2, 2, 2, 37, 138, 3, 2, 2, 2, 39, 140, 3, 2, 2, 2, 41, 148, 3, 2, 2, 2, 43, 154, 3, 2, 2, 2, 45, 167, 3, 2, 2, 2, 47, 181, 3, 2, 2, 2, 49, 183, 3, 2, 2, 2, 51, 185, 3, 2, 2, 2, 53, 187, 3, 2, 2, 2, 55, 189, 3, 2, 2, 2, 57, 191, 3, 2, 2, 2, 59, 193, 3, 2, 2, 2, 61, 196, 3, 2, 2, 2, 63, 199, 3, 2, 2, 2, 65, 202, 3, 2, 2, 2, 67, 205, 3, 2, 2, 2, 69, 208, 3, 2, 2, 2, 71, 211, 3, 2, 2, 2, 73, 214, 3, 2, 2, 2, 75, 227, 3, 2, 2, 2, 77, 238, 3, 2, 2, 2, 79, 241, 3, 2, 2, 2, 81, 245, 3, 2, 2, 2, 83, 253, 3, 2, 2, 2, 85, 263, 3, 2, 2, 2, 87, 265, 3, 2, 2, 2, 89, 90, 7, 42, 2, 2, 90, 4, 3, 2, 2, 2, 91, 92, 7, 43, 2, 2, 92, 6, 3, 2, 2, 2, 93, 94, 7, 46, 2, 2, 94, 8, 3, 2, 2, 2, 95, 96, 7, 93, 2, 2, 96, 10, 3, 2, 2, 2, 97, 98, 7, 95, 2, 2, 98, 12, 3, 2, 2, 2, 99, 100, 7, 107, 2, 2, 100, 101, 7, 104, 2, 2, 101, 14, 3, 2, 2, 2, 102, 103, 7, 103, 2, 2, 103, 104, 7, 110, 2, 2, 104, 105, 7, 117, 2, 2, 105, 106, 7, 103, 2, 2, 106, 16, 3, 2, 2, 2, 107, 108, 7, 110, 2, 2, 108, 109, 7, 103, 2, 2, 109, 110, 7, 118, 2, 2, 110, 18, 3, 2, 2, 2, 111, 112, 7, 63, 2, 2, 112, 20, 3, 2, 2, 2, 113, 114, 7, 61, 2, 2, 114, 22, 3, 2, 2, 2, 115, 116, 7, 125, 2, 2, 116, 24, 3, 2, 2, 2, 117, 118, 7, 127, 2, 2, 118, 26, 3, 2, 2, 2, 119, 120, 7, 104, 2, 2, 120, 121, 7, 112, 2, 2, 121, 28, 3, 2, 2, 2, 122, 123, 7, 47, 2, 2, 123, 124, 7, 64, 2, 2, 124, 30, 3, 2, 2, 2, 125, 126, 7, 102, 2, 2, 126, 127, 7, 103, 2, 2, 127, 128, 7, 104, 2, 2, 128, 32, 3, 2, 2, 2, 129, 130, 7, 60, 2, 2, 130, 34, 3, 2, 2, 2, 131, 132, 7, 86, 2, 2, 132, 133, 7, 103, 2, 2, 133, 134, 7, 112, 2, 2, 134, 135, 7, 117, 2, 2, 135, 136, 7, 113, 2, 2, 136, 137, 7, 116, 2, 2, 137, 36, 3, 2, 2, 2, 138, 139, 7, 97, 2, 2, 139, 38, 3, 2, 2, 2, 140, 141, 7, 120, 2, 2, 141, 142, 7, 50, 2, 2, 142, 143, 7, 48, 2, 2, 143, 144, 7, 50, 2, 2, 144, 145, 7, 48, 2, 2, 145, 146, 7, 52, 2, 2, 146, 40, 3, 2, 2, 2, 147, 149, 9, 2, 2, 2, 148, 147, 3, 2, 2, 2, 149, 150, 3, 2, 2, 2, 150, 148, 3, 2, 2, 2, 150, 151, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 153, 8, 21, 2, 2, 153, 42, 3, 2, 2, 2, 154, 155, 7, 49, 2, 2, 155, 156, 7, 49, 2, 2, 156, 160, 3, 2, 2, 2, 157, 159, 11, 2, 2, 2, 158, 157, 3, 2, 2, 2, 159, 162, 3, 2, 2, 2, 160, 161, 3, 2, 2, 2, 160, 158, 3, 2, 2, 2, 161, 163, 3, 2, 2, 2, 162, 160, 3, 2, 2, 2, 163, 164, 7, 12, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 8, 22, 2, 2, 166, 44, 3, 2, 2, 2, 167, 168, 7, 49, 2, 2, 168, 169, 7, 44, 2, 2, 169, 173, 3, 2, 2, 2, 170, 172, 11, 2, 2, 2, 171, 170, 3, 2, 2, 2, 172, 175, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 173, 171, 3, 2, 2, 2, 174, 176, 3, 2, 2, 2, 175, 173, 3, 2, 2, 2, 176, 177, 7, 44, 2, 2, 177, 178, 7, 49, 2, 2, 178, 179, 3, 2, 2, 2, 179, 180, 8, 23, 2, 2, 180, 46, 3, 2, 2, 2, 181, 182, 7, 44, 2, 2, 182, 48, 3, 2, 2, 2, 183, 184, 7, 49, 2, 2, 184, 50, 3, 2, 2, 2, 185, 186, 7, 45, 2, 2, 186, 52, 3, 2, 2, 2, 187, 188, 7, 47, 2, 2, 188, 54, 3, 2, 2, 2, 189, 190, 7, 62, 2, 2, 190, 56, 3, 2, 2, 2, 191, 192, 7, 64, 2, 2, 192, 58, 3, 2, 2, 2, 193, 194, 7, 62, 2, 2, 194, 195, 7, 63, 2, 2, 195, 60, 3, 2, 2, 2, 196, 197, 7, 64, 2, 2, 197, 198, 7, 63, 2, 2, 198, 62, 3, 2, 2, 2, 199, 200, 7, 63, 2, 2, 200, 201, 7, 63, 2, 2, 201, 64, 3, 2, 2, 2, 202, 203, 7, 35, 2, 2, 203, 204, 7, 63, 2, 2, 204, 66, 3, 2, 2, 2, 205, 206, 7, 66, 2, 2, 206, 207, 5, 83, 42, 2, 207, 68, 3, 2, 2, 2, 208, 209, 7, 39, 2, 2, 209, 210, 5, 83, 42, 2, 210, 70, 3, 2, 2, 2, 211, 212, 7, 39, 2, 2, 212, 213, 5, 79, 40, 2, 213, 72, 3, 2, 2, 2, 214, 215, 7, 111, 2, 2, 215, 216, 7, 119, 2, 2, 216, 217, 7, 118, 2, 2, 217, 74, 3, 2, 2, 2, 218, 219, 7, 86, 2, 2, 219, 220, 7, 116, 2, 2, 220, 221, 7, 119, 2, 2, 221, 228, 7, 103, 2, 2, 222, 223, 7, 72, 2, 2, 223, 224, 7, 99, 2, 2, 224, 225, 7, 110, 2, 2, 225, 226, 7, 117, 2, 2, 226, 228, 7, 103, 2, 2, 227, 218, 3, 2, 2, 2, 227, 222, 3, 2, 2, 2, 228, 76, 3, 2, 2, 2, 229, 230, 5, 79, 40, 2, 230, 231, 7, 48, 2, 2, 231, 233, 5, 79, 40, 2, 232, 234, 5, 81, 41, 2, 233, 232, 3, 2, 2, 2, 233, 234, 3, 2, 2, 2, 234, 239, 3, 2, 2, 2, 235, 236, 5, 79, 40, 2, 236, 237, 5, 81, 41, 2, 237, 239, 3, 2, 2, 2, 238, 229, 3, 2, 2, 2, 238, 235, 3, 2, 2, 2, 239, 78, 3, 2, 2, 2, 240, 242, 5, 87, 44, 2, 241, 240, 3, 2, 2, 2, 242, 243, 3, 2, 2, 2, 243, 241, 3, 2, 2, 2, 243, 244, 3, 2, 2, 2, 244, 80, 3, 2, 2, 2, 245, 247, 9, 3, 2, 2, 246, 248, 9, 4, 2, 2, 247, 246, 3, 2, 2, 2, 247, 248, 3, 2, 2, 2, 248, 249, 3, 2, 2, 2, 249, 250, 5, 79, 40, 2, 250, 82, 3, 2, 2, 2, 251, 254, 7, 97, 2, 2, 252, 254, 5, 85, 43, 2, 253, 251, 3, 2, 2, 2, 253, 252, 3, 2, 2, 2, 254, 260, 3, 2, 2, 2, 255, 259, 7, 97, 2, 2, 256, 259, 5, 85, 43, 2, 257, 259, 5, 87, 44, 2, 258, 255, 3, 2, 2, 2, 258, 256, 3, 2, 2, 2, 258, 257, 3, 2, 2, 2, 259, 262, 3, 2, 2, 2, 260, 258, 3, 2, 2, 2, 260, 261, 3, 2, 2, 2, 261, 84, 3, 2, 2, 2, 262, 260, 3, 2, 2, 2, 263, 264, 9, 5, 2, 2, 264, 86, 3, 2, 2, 2, 265, 266, 9, 6, 2, 2, 266, 88, 3, 2, 2, 2, 14, 2, 150, 160, 173, 227, 233, 238, 243, 247, 253, 258, 260, 3, 8, 2, 2]
\ No newline at end of file
T__0=1
T__1=2
T__2=3
T__3=4
T__4=5
T__5=6
T__6=7
T__7=8
T__8=9
T__9=10
T__10=11
T__11=12
T__12=13
T__13=14
T__14=15
T__15=16
T__16=17
T__17=18
SEMVER=19
WS=20
LINE_COMMENT=21
COMMENT=22
MUL=23
DIV=24
ADD=25
SUB=26
LT=27
GT=28
LE=29
GE=30
EQ=31
NE=32
GLOBAL_VAR=33
LOCAL_VAR=34
GRAPH_VAR=35
MUT=36
BOOL_LIT=37
FLOAT=38
NAT=39
CNAME=40
'('=1
')'=2
','=3
'['=4
']'=5
'if'=6
'else'=7
'let'=8
'='=9
';'=10
'{'=11
'}'=12
'fn'=13
'->'=14
'def'=15
':'=16
'Tensor'=17
'_'=18
'v0.0.2'=19
'*'=23
'/'=24
'+'=25
'-'=26
'<'=27
'>'=28
'<='=29
'>='=30
'=='=31
'!='=32
'mut'=36
# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2
from antlr4 import *
# This class defines a complete generic visitor for a parse tree produced by RelayParser.
class RelayVisitor(ParseTreeVisitor):
# Visit a parse tree produced by RelayParser#opIdent.
def visitOpIdent(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#prog.
def visitProg(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#identExpr.
def visitIdentExpr(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#call.
def visitCall(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#neg.
def visitNeg(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#tuple.
def visitTuple(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#parens.
def visitParens(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#funcExpr.
def visitFuncExpr(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#scalarExpr.
def visitScalarExpr(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#let.
def visitLet(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#tensor.
def visitTensor(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#ifElse.
def visitIfElse(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#graph.
def visitGraph(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#binOp.
def visitBinOp(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#func.
def visitFunc(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#defn.
def visitDefn(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#argList.
def visitArgList(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#varList.
def visitVarList(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#var.
def visitVar(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#attrList.
def visitAttrList(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#attr.
def visitAttr(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#typeParamSeq.
def visitTypeParamSeq(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#tupleType.
def visitTupleType(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#typeIdentType.
def visitTypeIdentType(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#tensorType.
def visitTensorType(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#funcType.
def visitFuncType(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#incompleteType.
def visitIncompleteType(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#intType.
def visitIntType(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#shapeSeq.
def visitShapeSeq(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#parensShape.
def visitParensShape(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#intShape.
def visitIntShape(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#typeIdent.
def visitTypeIdent(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#body.
def visitBody(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#scalarFloat.
def visitScalarFloat(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#scalarInt.
def visitScalarInt(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#scalarBool.
def visitScalarBool(self, ctx):
return self.visitChildren(ctx)
# Visit a parse tree produced by RelayParser#ident.
def visitIdent(self, ctx):
return self.visitChildren(ctx)
Relay* binary
Relay* linguist-generated=true
Relay* linguist-detectable=false
\ No newline at end of file
# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2 # Generated from /home/marisa/Work/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.1
from antlr4 import * from antlr4 import *
from io import StringIO from io import StringIO
from typing.io import TextIO from typing.io import TextIO
import sys import sys
def serializedATN(): def serializedATN():
with StringIO() as buf: with StringIO() as buf:
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2*") buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2*")
...@@ -195,7 +194,7 @@ class RelayLexer(Lexer): ...@@ -195,7 +194,7 @@ class RelayLexer(Lexer):
def __init__(self, input=None, output:TextIO = sys.stdout): def __init__(self, input=None, output:TextIO = sys.stdout):
super().__init__(input, output) super().__init__(input, output)
self.checkVersion("4.7.2") self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache()) self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None self._actions = None
self._predicates = None self._predicates = None
......
# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2 # Generated from /home/marisa/Work/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.1
# encoding: utf-8 # encoding: utf-8
from antlr4 import * from antlr4 import *
from io import StringIO from io import StringIO
from typing.io import TextIO from typing.io import TextIO
import sys import sys
def serializedATN(): def serializedATN():
with StringIO() as buf: with StringIO() as buf:
buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3*") buf.write("\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3*")
...@@ -260,13 +259,12 @@ class RelayParser ( Parser ): ...@@ -260,13 +259,12 @@ class RelayParser ( Parser ):
def __init__(self, input:TokenStream, output:TextIO = sys.stdout): def __init__(self, input:TokenStream, output:TextIO = sys.stdout):
super().__init__(input, output) super().__init__(input, output)
self.checkVersion("4.7.2") self.checkVersion("4.7.1")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache) self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None self._predicates = None
class OpIdentContext(ParserRuleContext): class OpIdentContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -304,7 +302,6 @@ class RelayParser ( Parser ): ...@@ -304,7 +302,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class ProgContext(ParserRuleContext): class ProgContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -381,7 +378,6 @@ class RelayParser ( Parser ): ...@@ -381,7 +378,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class ExprContext(ParserRuleContext): class ExprContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -440,8 +436,6 @@ class RelayParser ( Parser ): ...@@ -440,8 +436,6 @@ class RelayParser ( Parser ):
super().__init__(parser) super().__init__(parser)
self.copyFrom(ctx) self.copyFrom(ctx)
def SUB(self):
return self.getToken(RelayParser.SUB, 0)
def expr(self): def expr(self):
return self.getTypedRuleContext(RelayParser.ExprContext,0) return self.getTypedRuleContext(RelayParser.ExprContext,0)
...@@ -628,26 +622,6 @@ class RelayParser ( Parser ): ...@@ -628,26 +622,6 @@ class RelayParser ( Parser ):
else: else:
return self.getTypedRuleContext(RelayParser.ExprContext,i) return self.getTypedRuleContext(RelayParser.ExprContext,i)
def MUL(self):
return self.getToken(RelayParser.MUL, 0)
def DIV(self):
return self.getToken(RelayParser.DIV, 0)
def ADD(self):
return self.getToken(RelayParser.ADD, 0)
def SUB(self):
return self.getToken(RelayParser.SUB, 0)
def LT(self):
return self.getToken(RelayParser.LT, 0)
def GT(self):
return self.getToken(RelayParser.GT, 0)
def LE(self):
return self.getToken(RelayParser.LE, 0)
def GE(self):
return self.getToken(RelayParser.GE, 0)
def EQ(self):
return self.getToken(RelayParser.EQ, 0)
def NE(self):
return self.getToken(RelayParser.NE, 0)
def accept(self, visitor:ParseTreeVisitor): def accept(self, visitor:ParseTreeVisitor):
if hasattr( visitor, "visitBinOp" ): if hasattr( visitor, "visitBinOp" ):
...@@ -1037,7 +1011,6 @@ class RelayParser ( Parser ): ...@@ -1037,7 +1011,6 @@ class RelayParser ( Parser ):
self.unrollRecursionContexts(_parentctx) self.unrollRecursionContexts(_parentctx)
return localctx return localctx
class FuncContext(ParserRuleContext): class FuncContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1115,7 +1088,6 @@ class RelayParser ( Parser ): ...@@ -1115,7 +1088,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class DefnContext(ParserRuleContext): class DefnContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1199,7 +1171,6 @@ class RelayParser ( Parser ): ...@@ -1199,7 +1171,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class ArgListContext(ParserRuleContext): class ArgListContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1265,7 +1236,6 @@ class RelayParser ( Parser ): ...@@ -1265,7 +1236,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class VarListContext(ParserRuleContext): class VarListContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1327,7 +1297,6 @@ class RelayParser ( Parser ): ...@@ -1327,7 +1297,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class VarContext(ParserRuleContext): class VarContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1381,7 +1350,6 @@ class RelayParser ( Parser ): ...@@ -1381,7 +1350,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class AttrListContext(ParserRuleContext): class AttrListContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1442,7 +1410,6 @@ class RelayParser ( Parser ): ...@@ -1442,7 +1410,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class AttrContext(ParserRuleContext): class AttrContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1488,7 +1455,6 @@ class RelayParser ( Parser ): ...@@ -1488,7 +1455,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class TypeParamSeqContext(ParserRuleContext): class TypeParamSeqContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1562,7 +1528,6 @@ class RelayParser ( Parser ): ...@@ -1562,7 +1528,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class Type_Context(ParserRuleContext): class Type_Context(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1836,7 +1801,6 @@ class RelayParser ( Parser ): ...@@ -1836,7 +1801,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class ShapeSeqContext(ParserRuleContext): class ShapeSeqContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -1924,7 +1888,6 @@ class RelayParser ( Parser ): ...@@ -1924,7 +1888,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class ShapeContext(ParserRuleContext): class ShapeContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -2010,7 +1973,6 @@ class RelayParser ( Parser ): ...@@ -2010,7 +1973,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class TypeIdentContext(ParserRuleContext): class TypeIdentContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -2048,7 +2010,6 @@ class RelayParser ( Parser ): ...@@ -2048,7 +2010,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class BodyContext(ParserRuleContext): class BodyContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -2091,7 +2052,6 @@ class RelayParser ( Parser ): ...@@ -2091,7 +2052,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class ScalarContext(ParserRuleContext): class ScalarContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
...@@ -2194,7 +2154,6 @@ class RelayParser ( Parser ): ...@@ -2194,7 +2154,6 @@ class RelayParser ( Parser ):
self.exitRule() self.exitRule()
return localctx return localctx
class IdentContext(ParserRuleContext): class IdentContext(ParserRuleContext):
def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1):
......
# Generated from /home/sslyu/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.2 # Generated from /home/marisa/Work/tvm/python/tvm/relay/grammar/Relay.g4 by ANTLR 4.7.1
from antlr4 import * from antlr4 import *
if __name__ is not None and "." in __name__: if __name__ is not None and "." in __name__:
from .RelayParser import RelayParser from .RelayParser import RelayParser
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment