-
Notifications
You must be signed in to change notification settings - Fork 559
Add stack frame id metadata and correct filename and line number for custom op_name #5838
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
51a15d9
Add python binding to allow custom op_name metadata for lowere HLO
mrnikwaws 7d39252
Lint fix for clang-format
mrnikwaws b9eb7dc
Lint fix for customer op_name test code
mrnikwaws c5f74b1
Requested nit changes
mrnikwaws 457dd85
As discussed increase timeout on GPU tests by 20%
mrnikwaws b951da4
Merge branch 'pytorch:master' into master
mrnikwaws 6b72c56
Add lowering for stack frame index and stack frame id in metadata
mrnikwaws 20532a9
Add fix for stack depth when using set custom op_name in a python con…
mrnikwaws b266fd4
Changes after adding tests for lowered stack frames and finding sever…
mrnikwaws 3a03d23
Lint fixes
mrnikwaws a16b9cf
Cleanup old code / comments
mrnikwaws ef0dba1
Add routine to XlaNode to search back through operands and recusively…
mrnikwaws a2d92bf
Fix recursion condition so we don't explore nodes with metadata
mrnikwaws b17e700
Refactor stack frame builder into a separate class as requested by re…
mrnikwaws File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| #include <torch/csrc/lazy/core/hash.h> | ||
| #include <torch/csrc/lazy/core/ir.h> | ||
| #include <torch/csrc/lazy/core/ir_builder.h> | ||
| #include <torch/csrc/lazy/core/ir_metadata.h> | ||
|
|
||
| #include <functional> | ||
| #include <iostream> | ||
|
|
@@ -146,8 +147,8 @@ class XlaNode : public torch::lazy::Node { | |
| return unbounded_dynamic_dims_; | ||
| } | ||
|
|
||
| void SetCustomOpName(const std::string& op_name); | ||
| const std::string& custom_op_name() const { return custom_op_name_; } | ||
| std::shared_ptr<torch::lazy::UserMetaData> SetUserMetadataForSubGraph( | ||
| std::shared_ptr<torch::lazy::UserMetaData> user_meta); | ||
|
|
||
| protected: | ||
| std::unordered_set<uint32_t> unbounded_dynamic_dims_; | ||
|
|
@@ -170,8 +171,6 @@ class XlaNode : public torch::lazy::Node { | |
|
|
||
| // Experimental sharding annotations attached to the IR node. | ||
| std::vector<std::shared_ptr<xla::OpSharding>> output_shardings_; | ||
|
|
||
| std::string custom_op_name_; | ||
| }; | ||
|
|
||
| inline std::ostream& operator<<(std::ostream& stream, const XlaNode& node) { | ||
|
|
@@ -195,6 +194,15 @@ T* NodeCast(const torch::lazy::Node* node, torch::lazy::OpKind op) { | |
| return const_cast<T*>(casted); | ||
| } | ||
|
|
||
| struct CustomOpNameMetaData : public torch::lazy::UserMetaData { | ||
| CustomOpNameMetaData(const std::string& input_op_name_prefix, | ||
| int input_max_stack_depth) | ||
| : op_name_prefix(input_op_name_prefix), | ||
| max_stack_depth(input_max_stack_depth) {} | ||
| std::string op_name_prefix; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's make this struct to contain the exact things you need to override in HLO proto, i.e. |
||
| size_t max_stack_depth; | ||
| }; | ||
|
|
||
| } // namespace torch_xla | ||
|
|
||
| #endif // XLA_TORCH_XLA_CSRC_IR_H_ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to
_set_user_metadataand take a torch::lazy::UserMetadata if possible.Let's pass in everything that can be forwarded to HLO here (like filename, line num, whatever Indexes etc); so no computation happens in C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can pass in a python dict (which becomes a map here) with all needed content and do creation of CustomOpNameMetadata if you feel exposing CustomOpNameMetadata through pybind11 is too much work.