Skip to content

Conversation

ttanpcs
Copy link

@ttanpcs ttanpcs commented Jun 30, 2022

Stack from ghstack (oldest at bottom):

  • Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
  • Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
  • Tested is_mutable method overloads in new test_schema_info.cpp file.

Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits

Differential Revision: D37651384

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 30, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

As of commit 6033932 (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jun 30, 2022
ttanpcs pushed a commit that referenced this pull request Jun 30, 2022
…ubclass

ghstack-source-id: c21f7cd
Pull Request resolved: #80734
ttanpcs pushed a commit that referenced this pull request Jun 30, 2022
…ubclass

ghstack-source-id: af25011
Pull Request resolved: #80734
@ttanpcs
Copy link
Author

ttanpcs commented Jul 6, 2022

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

…chemaInfo subclass"


- Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
- Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
- Tested is_mutable method overloads in new test_schema_info.cpp file. 

**Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits**

Differential Revision: [D37651384](https://our.internmc.facebook.com/intern/diff/D37651384)

[ghstack-poisoned]
@ttanpcs
Copy link
Author

ttanpcs commented Jul 6, 2022

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

Copy link
Contributor

@davidberard98 davidberard98 left a comment

Choose a reason for hiding this comment

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

LGTM!


namespace torch {
namespace utils {
namespace {
Copy link
Contributor

Choose a reason for hiding this comment

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

very minor nit / my personal preference: I think this doesn't need to be in an anonymous namespace. AFAIK we typically put utility functions and functions that are only used within a given cpp file into an anonymous namespace, but tests are sort of user-facing (and also most of the other jit test files don't put the tests in anonymous namespaces)

goldenxuett added 2 commits July 6, 2022 11:27
…chemaInfo subclass"


- Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
- Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
- Tested is_mutable method overloads in new test_schema_info.cpp file. 

**Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits**

Differential Revision: [D37651384](https://our.internmc.facebook.com/intern/diff/D37651384)

[ghstack-poisoned]
…chemaInfo subclass"


- Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
- Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
- Tested is_mutable method overloads in new test_schema_info.cpp file. 

**Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits**

Differential Revision: [D37651384](https://our.internmc.facebook.com/intern/diff/D37651384)

[ghstack-poisoned]
ttanpcs pushed a commit that referenced this pull request Jul 6, 2022
…ubclass

ghstack-source-id: c444cec
Pull Request resolved: #80734
@ttanpcs
Copy link
Author

ttanpcs commented Jul 6, 2022

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

Comment on lines 12 to 22
* Subclass of FunctionSchema that publicizes argument value specific operator
* behavior (mutation, aliasing, special cases, etc...)
*/

struct TORCH_API SchemaInfo : c10::FunctionSchema {
public:
explicit SchemaInfo(c10::FunctionSchema schema) : FunctionSchema(schema) {}
explicit SchemaInfo(const char* signature)
: FunctionSchema(torch::jit::getOperatorForLiteral(signature)->schema()) {
}
};
Copy link
Contributor

@Gamrix Gamrix Jul 6, 2022

Choose a reason for hiding this comment

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

@davidberard98 Should we be concerned about performance impacts from virtualizing FunctionSchema? FunctionSchema is used in Core.

A way to avoid this is by using composition instead of inheritance.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are any methods on FunctionSchema actually getting virtualized in this PR? It looks like SchemaInfo inherits from FunctionSchema` (but without virtualizing any methods). I think that should be fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bdhirsh but in future PRs there would presumably be some virtualized methods (i.e. is_mutable, which on FunctionSchema will return static results but on SchemaInfo will return data-dependent results)

Copy link
Contributor

Choose a reason for hiding this comment

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

@bdhirsh Look at https://github.com/pytorch/pytorch/pull/80972/files for functions in SchemaInfo that we would be virtualizing. (They are currently not marked as virtual, but I expect that we would need them to be virtual in order for things to work as intended).

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok, in agreement with John then on composition over inheritance. FunctionSchema is probably hot-path enough that we want to avoid virtualizing some of its common methods.

…chemaInfo subclass"


- Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
- Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
- Tested is_mutable method overloads in new test_schema_info.cpp file. 

**Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits**

Differential Revision: [D37651384](https://our.internmc.facebook.com/intern/diff/D37651384)

[ghstack-poisoned]
ttanpcs pushed a commit that referenced this pull request Jul 8, 2022
…ubclass

ghstack-source-id: 17b9e24
Pull Request resolved: #80734
@ttanpcs
Copy link
Author

ttanpcs commented Jul 8, 2022

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

@ttanpcs ttanpcs requested review from davidberard98 and removed request for davidberard98 July 8, 2022 16:42
…chemaInfo subclass"


- Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
- Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
- Tested is_mutable method overloads in new test_schema_info.cpp file. 

**Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits**

Differential Revision: [D37651384](https://our.internmc.facebook.com/intern/diff/D37651384)

[ghstack-poisoned]
ttanpcs pushed a commit that referenced this pull request Jul 8, 2022
…ubclass

ghstack-source-id: 68bfa9f
Pull Request resolved: #80734
@ttanpcs
Copy link
Author

ttanpcs commented Jul 8, 2022

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

Copy link
Contributor

@davidberard98 davidberard98 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!

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here

@github-actions
Copy link
Contributor

Hey @goldenxuett.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Jul 11, 2022
…ubclass (#80734)

Summary:
Pull Request resolved: #80734

- Added overloads to is_mutable method in FunctionSchema to tell whether an argument at index is mutable or an argument with name is mutable.
- Created SchemaInfo subclass of FunctionSchema with constructors from FunctionSchema and from const char* signature.
- Tested is_mutable method overloads in new test_schema_info.cpp file.

**Note that this pr is used to set up SchemaInfo. Implementation for SchemaInfo will be addressed in later commits**

Test Plan: Imported from OSS

Reviewed By: davidberard98

Differential Revision: D37651384

Pulled By: goldenxuett

fbshipit-source-id: 5e3f618758590ad518cfbd14f0ab50f010049e09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants