Commit 242daeea by Wei Chen Committed by Tianqi Chen

[RELAY] Fix function call parsing for binary op (#2424)

parent 6737739c
......@@ -53,14 +53,15 @@ prog: (defn* | expr) EOF ;
expr
// operators
: '(' expr ')' # parens
// function application
| expr '(' (expr (',' expr)*)? ')' # call
| '-' expr # neg
| expr op=('*'|'/') expr # binOp
| expr op=('+'|'-') expr # binOp
| expr op=('<'|'>'|'<='|'>=') expr # binOp
| expr op=('=='|'!=') expr # binOp
// function definition and application
| expr '(' (expr (',' expr)*)? ')' # call
// function definition
| func # funcExpr
// tuples and tensors
......
......@@ -316,6 +316,22 @@ def test_ifelse_scope():
@if_parser_enabled
def test_call():
# select right function to call: simple ident case
id_func = relay.Var("id")
assert alpha_equal(
relay.fromtext(
"""
let %id = fn (%x) { %x };
10 * %id(10)
"""
),
relay.Let(
id_func,
relay.Function([X], X, None, []),
relay.multiply(relay.const(10), relay.Call(id_func, [relay.const(10)]))
)
)
# 0 args
constant = relay.Var("constant")
assert alpha_equal(
......
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