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
242daeea
Commit
242daeea
authored
Jan 14, 2019
by
Wei Chen
Committed by
Tianqi Chen
Jan 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RELAY] Fix function call parsing for binary op (#2424)
parent
6737739c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
python/tvm/relay/grammar/Relay.g4
+3
-2
tests/python/relay/test_ir_parser.py
+16
-0
No files found.
python/tvm/relay/grammar/Relay.g4
View file @
242daeea
...
@@ -53,14 +53,15 @@ prog: (defn* | expr) EOF ;
...
@@ -53,14 +53,15 @@ prog: (defn* | expr) EOF ;
expr
expr
// operators
// operators
: '(' expr ')' # parens
: '(' expr ')' # parens
// function application
| expr '(' (expr (',' expr)*)? ')' # call
| '-' expr # neg
| '-' expr # neg
| expr op=('*'|'/') expr # binOp
| expr op=('*'|'/') expr # binOp
| expr op=('+'|'-') expr # binOp
| expr op=('+'|'-') expr # binOp
| expr op=('<'|'>'|'<='|'>=') expr # binOp
| expr op=('<'|'>'|'<='|'>=') expr # binOp
| expr op=('=='|'!=') expr # binOp
| expr op=('=='|'!=') expr # binOp
// function definition and application
// function definition
| expr '(' (expr (',' expr)*)? ')' # call
| func # funcExpr
| func # funcExpr
// tuples and tensors
// tuples and tensors
...
...
tests/python/relay/test_ir_parser.py
View file @
242daeea
...
@@ -316,6 +316,22 @@ def test_ifelse_scope():
...
@@ -316,6 +316,22 @@ def test_ifelse_scope():
@if_parser_enabled
@if_parser_enabled
def
test_call
():
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
# 0 args
constant
=
relay
.
Var
(
"constant"
)
constant
=
relay
.
Var
(
"constant"
)
assert
alpha_equal
(
assert
alpha_equal
(
...
...
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