-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[PyTorch] Avoid schema parsing in lightweight dispatch #74069
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
Conversation
CI Flow Status⚛️ CI FlowRuleset - Version:
|
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit ffb9b64 (more details on the Dr. CI page):
🕵️ 5 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
|
This pull request was exported from Phabricator. Differential Revision: D33077733 |
|
This pull request was exported from Phabricator. Differential Revision: D33077733 |
3aa6c95 to
88b71be
Compare
|
This pull request was exported from Phabricator. Differential Revision: D33077733 |
88b71be to
9f49e83
Compare
|
This pull request was exported from Phabricator. Differential Revision: D33077733 |
9f49e83 to
0f9cbfb
Compare
|
This pull request was exported from Phabricator. Differential Revision: D33077733 |
0f9cbfb to
1c25f83
Compare
Summary: Pull Request resolved: pytorch#74069 RFC: pytorch/rfcs#40 In pytorch#69881 we added the ability to generate codegen unboxing source files. Notice that the generated code to register an operator looks like this: ``` // aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor OperatorGenerator( TORCH_SELECTIVE_SCHEMA("aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor"), [](Stack & stack) { RECORD_FUNCTION("add", std::vector<c10::IValue>()); at::unboxing::add_Tensor(stack); }, aliasAnalysisFromSchema() ), ``` However, this means we have to parse the schema and get back arguments with default values in static init time. As written in the RFC, there's a more performant option: providing these arguments with default values using codegen, then we don't have to do expensive regex pattern matching in parsing. Here's how it looks like: ``` // aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor OperatorGenerator( "aten::add", "Tensor", { c10::Argument("self", nullptr, c10::nullopt, c10::IValue(c10::nullopt)), c10::Argument("other", nullptr, c10::nullopt, c10::IValue(c10::nullopt)), c10::Argument("alpha", nullptr, c10::nullopt, c10::IValue(1)) }, { c10::Argument("") }, [](Stack & stack) { RECORD_FUNCTION("add", std::vector<c10::IValue>()); at::unboxing::add_Tensor(stack); }, aliasAnalysisFromSchema() ), ``` We also added corresponding APIs in `operator.h` to take in the arguments. Test Plan: Rely on CI Reviewed By: kimishpatel Differential Revision: D33077733 fbshipit-source-id: db6fcb3066ba352cb338a018324c02c32d67b941
|
This pull request was exported from Phabricator. Differential Revision: D33077733 |
1c25f83 to
ffb9b64
Compare
Summary: Pull Request resolved: #74069 RFC: pytorch/rfcs#40 In #69881 we added the ability to generate codegen unboxing source files. Notice that the generated code to register an operator looks like this: ``` // aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor OperatorGenerator( TORCH_SELECTIVE_SCHEMA("aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor"), [](Stack & stack) { RECORD_FUNCTION("add", std::vector<c10::IValue>()); at::unboxing::add_Tensor(stack); }, aliasAnalysisFromSchema() ), ``` However, this means we have to parse the schema and get back arguments with default values in static init time. As written in the RFC, there's a more performant option: providing these arguments with default values using codegen, then we don't have to do expensive regex pattern matching in parsing. Here's how it looks like: ``` // aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor OperatorGenerator( "aten::add", "Tensor", { c10::Argument("self", nullptr, c10::nullopt, c10::IValue(c10::nullopt)), c10::Argument("other", nullptr, c10::nullopt, c10::IValue(c10::nullopt)), c10::Argument("alpha", nullptr, c10::nullopt, c10::IValue(1)) }, { c10::Argument("") }, [](Stack & stack) { RECORD_FUNCTION("add", std::vector<c10::IValue>()); at::unboxing::add_Tensor(stack); }, aliasAnalysisFromSchema() ), ``` We also added corresponding APIs in `operator.h` to take in the arguments. Test Plan: Rely on CI Reviewed By: kimishpatel Differential Revision: D33077733 fbshipit-source-id: e7f13a2f162c70d4e506b4f64cdbb7afec39f4e6
|
Hey @larryliu0820. |
Summary:
RFC: pytorch/rfcs#40
In #69881 we added the ability to generate codegen unboxing source files. Notice that the generated code to register an operator looks like this:
However, this means we have to parse the schema and get back arguments with default values in static init time. As written in the RFC, there's a more performant option: providing these arguments with default values using codegen, then we don't have to do expensive regex pattern matching in parsing. Here's how it looks like:
We also added corresponding APIs in
operator.hto take in the arguments.Test Plan: Rely on CI
Differential Revision: D33077733