Skip to content

Commit

Permalink
attempt at adding antlr4 to cmake. remove outdated grammar rules. upd…
Browse files Browse the repository at this point in the history
…ate tests
  • Loading branch information
joshpoll committed Oct 13, 2018
1 parent 132e2c2 commit e75de2c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,27 @@ else(INSTALL_DEV)
)
endif(INSTALL_DEV)

# ANTLR4 build definitions
# find_program(ANTLR4 antlr4)

# set(RELAY_PARSER_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/relay/python/relay/parser)

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

# if(ANTLR4)
# # Generate ANTLR grammar for parsing.
# add_custom_command(OUTPUT ${RELAY_PARSER}
# COMMAND antlr4 -visitor -no-listener -Dlanguage=Python3 ${RELAY_PARSER_DIR}/Relay.g4 -o ${RELAY_PARSER_DIR}
# DEPENDS ${RELAY_PARSER_DIR}/Relay.g4
# WORKING_DIRECTORY ${RELAY_PARSER_DIR})
# endif()

# add_custom_target(relay_parser ALL DEPENDS ${RELAY_PARSER})

# More target definitions
if(MSVC)
target_compile_definitions(tvm PRIVATE -DHalide_EXPORTS)
Expand Down
2 changes: 0 additions & 2 deletions python/tvm/relay/grammar/Relay.g4
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,9 @@ type_
| '(' type_ ',' ')' # tupleType
| '(' type_ (',' type_)+ ')' # tupleType
| identType # identTypeType
| identType '(' (type_ (',' type_)*)? ')' # callType
| identType '[' (type_ (',' type_)*)? ']' # callType
| '(' (type_ (',' type_)*)? ')' '->' type_ # funcType
// Mut, Int, UInt, Float, Bool, Tensor
// | type_ '.' INT # projectType
| INT # intType
| '_' # incompleteType
;
Expand Down
5 changes: 1 addition & 4 deletions tests/python/relay/test_ir_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,7 @@ def test_call_type():
# let %_ : Int(0, 1) = (); ()
for call_type, arity in CALL_TYPES.items():
for i in range(1, arity + 1):
# custom tuple printing to avoid hanging comma for one-tuples
tup = "(" + ",".join([str(num) for num in range(i)]) + ")"
print("let %_ : {}{} = (); ()".format(call_type, tup))
parse_expr("let %_ : {}{} = (); ()".format(call_type, tup))
parse_expr("let %_ : {}{} = (); ()".format(call_type, range(i)))

def test_function_type():
assert alpha_equal(
Expand Down

0 comments on commit e75de2c

Please sign in to comment.