Skip to content

Align native_functions.yaml func schema more with JIT signature schema#16111

Closed
cpuhrsch wants to merge 16 commits intopytorch:masterfrom
cpuhrsch:simplematches
Closed

Align native_functions.yaml func schema more with JIT signature schema#16111
cpuhrsch wants to merge 16 commits intopytorch:masterfrom
cpuhrsch:simplematches

Conversation

@cpuhrsch
Copy link
Contributor

@cpuhrsch cpuhrsch commented Jan 17, 2019

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

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jan 17, 2019
@cpuhrsch cpuhrsch force-pushed the simplematches branch 4 times, most recently from 6298d9f to 224416f Compare January 17, 2019 21:43
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't "int[]" be together with temp_type_translations?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the initializer list stuff is just wrong now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you repeat matches_jit_signature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean default argument here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this actually work in JIT? Like, how does it know what Mean is in parsing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't. It does the inverse of this, which is translating 'Reduction::Mean' to 'Mean'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused -- "Tensor? x=[]" isn't the legacy -- when I looked in native_functions.yaml now, Tensor? weight={} is used.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cpuhrsch has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@cpuhrsch cpuhrsch changed the title [DRAFT] Align native_functions.yaml func schema more with JIT signature schema Align native_functions.yaml func schema more with JIT signature schema Jan 22, 2019
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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] + "}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is there no [temp translations] label here?

default = None

# Enables Generator? by translating to legacy Generator*. See [temp translations]
if t == 'Generator?':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

zdevito pushed a commit to zdevito/ATen that referenced this pull request Jan 23, 2019
…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
@ezyang ezyang added the merged label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants