Align native_functions.yaml func schema more with JIT signature schema#16111
Align native_functions.yaml func schema more with JIT signature schema#16111cpuhrsch wants to merge 16 commits intopytorch:masterfrom
Conversation
6298d9f to
224416f
Compare
aten/src/ATen/native_parse.py
Outdated
There was a problem hiding this comment.
shouldn't "int[]" be together with temp_type_translations?
facebook-github-bot
left a comment
There was a problem hiding this comment.
@cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
aten/src/ATen/native/README.md
Outdated
There was a problem hiding this comment.
there are still a bunch of references to old types in this file that should be updated, e.g. Generator*, double when referring to the non-C++ schema, etc.
There was a problem hiding this comment.
also the initializer list stuff is just wrong now.
There was a problem hiding this comment.
you repeat matches_jit_signature.
aten/src/ATen/native_parse.py
Outdated
There was a problem hiding this comment.
you mean default argument here?
aten/src/ATen/native_parse.py
Outdated
There was a problem hiding this comment.
how does this actually work in JIT? Like, how does it know what Mean is in parsing?
There was a problem hiding this comment.
It doesn't. It does the inverse of this, which is translating 'Reduction::Mean' to 'Mean'.
aten/src/ATen/native_parse.py
Outdated
There was a problem hiding this comment.
I'm confused -- "Tensor? x=[]" isn't the legacy -- when I looked in native_functions.yaml now, Tensor? weight={} is used.
15aba97 to
43eb7e7
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
@cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
a68e2f5 to
acd1353
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
@cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| elif re.match(r'{.*}', s): | ||
| return s | ||
| elif re.match(r'\[.*\]', s): | ||
| return "{" + s[1:-1] + "}" |
There was a problem hiding this comment.
This is not an actionable comment, but it's kind of irritating the temp translations have to be spattered all over the code. Good thing they're labeled [temp translations]
facebook-github-bot
left a comment
There was a problem hiding this comment.
@cpuhrsch is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
| return '{}' | ||
| elif re.match(r'{.*}', s): | ||
| return s | ||
| elif re.match(r'\[.*\]', s): |
There was a problem hiding this comment.
nit: it's not obvious what's a temp translation and what's not without looking at the diff here.
| return 'c10::nullopt' | ||
| # The JIT signature schema uses Mean, but in particular C++ needs | ||
| # the legacy Reduction::Mean. So we'll continue emiting that until | ||
| # we change this at either a JIT schema or C++ level. |
There was a problem hiding this comment.
why is there no [temp translations] label here?
| default = None | ||
|
|
||
| # Enables Generator? by translating to legacy Generator*. See [temp translations] | ||
| if t == 'Generator?': |
There was a problem hiding this comment.
I think this could be simpler if you wrote another function temp_default_translations(default, type) and put all the special logic that isn't in temp_type_translations there.
Taking out the translations should basically require no thinking -- just rip out the entry from either temp_default_translations(default, type) or temp_type_translations
…a (#16111)
Summary:
This PR applies a few minor modifications leading to 100s of additional matches
Modifications to native_functions.yaml
1) double to float
2) int64_t to int
3) IntList[\d*] to int[\d*]
4) {} to []
5) Tensor? x=[] to Tensor? x=None
6) TensorList to Tensor[]
7) 1e-x to 1e-0x
8) Generator* x = nullptr to Generator? x = None
9) `{.*}` to `[.*]`
Overall this adds about 300 new matches and brings us to about 1/2 compliance of native_functions func with their JIT signature equivalent
While this is still a draft "tools/jit/gen_jit_dispatch.py" contains code to aid in finding close signatures
Pull Request resolved: pytorch/pytorch#16111
Reviewed By: ezyang
Differential Revision: D13738123
Pulled By: cpuhrsch
fbshipit-source-id: d1ec1e089bdb26ec155f6f31ccf768270acb76c7
This PR applies a few minor modifications leading to 100s of additional matches
Modifications to native_functions.yaml
{.*}to[.*]Overall this adds about 300 new matches and brings us to about 1/2 compliance of native_functions func with their JIT signature equivalent
While this is still a draft "tools/jit/gen_jit_dispatch.py" contains code to aid in finding close signatures