Skip to content

[JIT] Add registerOperator overloads that infer the schema#10048

Closed
goldsborough wants to merge 9 commits intopytorch:masterfrom
goldsborough:register-op
Closed

[JIT] Add registerOperator overloads that infer the schema#10048
goldsborough wants to merge 9 commits intopytorch:masterfrom
goldsborough:register-op

Conversation

@goldsborough
Copy link
Contributor

@goldsborough goldsborough commented Jul 31, 2018

This PR adds a way to infer the JIT/script schema of a function from its signature, and then create an operator from the schema and implementation. The implementation function is wrapped into another function, which pops values from the stack into an argument tuple, then invokes the function and pushes the return value back onto the stack, sometimes unpacking the return value if it is a tuple.

Currently the method is called createOperator. We may want to think of a nicer way of registering ops in tandem with RegisterOperators. It might be very cumbersome to add a template constructor to Operator, so maybe we can come up with a chaining method on RegisterOperators like RegisterOperators(schema, func).op(schema.func).op(schema, func) -- it has to work at startup time (for a static variable) though. We can solve this in another PR.

@zdevito @apaszke @smessmer @dzhulgakov

This comment was marked as off-topic.

This comment was marked as off-topic.

@goldsborough goldsborough added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jul 31, 2018
@goldsborough goldsborough changed the title [WIP][JIT] Add registerOperator overloads that infer the schema [JIT] Add registerOperator overloads that infer the schema Aug 1, 2018
@goldsborough goldsborough force-pushed the register-op branch 2 times, most recently from c8920a2 to 85a0270 Compare August 1, 2018 17:10
@goldsborough
Copy link
Contributor Author

@zdevito can you take another look?
@smessmer can you approve the changes to your Metaprogramming.h?

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

Looks good! Minor comments. Template meta-programming is just on the border of being understandable, which is nice.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

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.

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

@goldsborough
Copy link
Contributor Author

@zdevito check the latest commit (Better support for lists)

Copy link
Contributor

@smessmer smessmer left a comment

Choose a reason for hiding this comment

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

LGTM

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@goldsborough
Copy link
Contributor Author

@pytorchbot retest this please

@goldsborough goldsborough force-pushed the register-op branch 2 times, most recently from 6985525 to e230aeb Compare August 2, 2018 21:10
@goldsborough
Copy link
Contributor Author

@pytorchbot retest this please

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.

goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

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.

zdevito is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@goldsborough goldsborough deleted the register-op branch August 3, 2018 18:51
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary:
This PR adds a way to infer the JIT/script schema of a function from its signature, and then create an operator from the schema and implementation. The implementation function is wrapped into another function, which pops values from the stack into an argument tuple, then invokes the function and pushes the return value back onto the stack, sometimes unpacking the return value if it is a tuple.

Currently the method is called `createOperator`. We may want to think of a nicer way of registering ops in tandem with `RegisterOperators`. It might be very cumbersome to add a template constructor to `Operator`, so maybe we can come up with a chaining method on `RegisterOperators` like `RegisterOperators(schema, func).op(schema.func).op(schema, func)` -- it has to work at startup time (for a static variable) though. We can solve this in another PR.

zdevito apaszke smessmer dzhulgakov
Pull Request resolved: pytorch#10048

Differential Revision: D9125975

Pulled By: goldsborough

fbshipit-source-id: de9e59888757573284a43787ae5d94384bfe8f9a
@ezyang ezyang added the merged label Jun 26, 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