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][Parser] Support slash in identifier. #8352

Merged
merged 3 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 1 deletion src/parser/tokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ bool IsNumeric(char c) {
!IsWhitespace(c);
}

bool IsIdentLetter(char c) { return '_' == c || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); }
bool IsIdentLetter(char c) {
return '_' == c || c == '/' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
}

bool IsIdent(char c) { return IsIdentLetter(c) || IsDigit(c); }

Expand Down
9 changes: 9 additions & 0 deletions tests/python/relay/test_ir_text_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,5 +284,14 @@ def test_optional_info():
assert txt.count("/* ty=int32 */") == 3


def test_slash_in_identifier():
x = relay.var("base/x")
y = relay.var("base/y")
z = x + y
txt = astext(z)
zackcquic marked this conversation as resolved.
Show resolved Hide resolved
assert "base/x" in txt
assert "base/y" in txt


if __name__ == "__main__":
pytest.main([__file__])