mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Profiler] Weaken ordering check during post processing.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/78563 The profiler assembles a call hierarchy by replaying recorded events. There is an assert to ensure that the events form a well structured tree; however many of the inputs are from external sources and small differences (e.g. recording time in a lower precision) leads to traces which violate that assumption. For now this is acceptable; the post processing can handle resolving these descrepencies. As a result, I am relaxing the assert to only test event types where we expect the framework to be able to enforce these strong structural requirements. Differential Revision: [D36787787](https://our.internmc.facebook.com/intern/diff/D36787787/) Approved by: https://github.com/suo
This commit is contained in:
@ -70,7 +70,7 @@ TEST(MobileProfiler, ModuleHierarchy) {
|
||||
ASSERT_TRUE(checkMetaData("aten::add", metadata_name, "top(C)::<unknown>.aten::add", trace_file));
|
||||
}
|
||||
|
||||
TEST(MobileProfiler, DISABLED_Backend) {
|
||||
TEST(MobileProfiler, Backend) {
|
||||
std::string filePath(__FILE__);
|
||||
auto testModelFile = filePath.substr(0, filePath.find_last_of("/\\") + 1);
|
||||
testModelFile.append("test_backend_for_profiling.ptl");
|
||||
|
@ -392,19 +392,8 @@ void build_tree(std::vector<std::shared_ptr<Result>>& events) {
|
||||
auto start_tid = event->start_tid_;
|
||||
auto frame = stacks.at(start_tid);
|
||||
|
||||
// Handle any events which are allowed to end without an explicit end call.
|
||||
// (E.g. a user scope.)
|
||||
while (frame.get() != event.get()) {
|
||||
TORCH_INTERNAL_ASSERT(frame != nullptr);
|
||||
c10::visit(
|
||||
c10::overloaded(
|
||||
[](const op_fields& i) {
|
||||
TORCH_INTERNAL_ASSERT(
|
||||
i.scope_ == at::RecordScope::USER_SCOPE, (int)i.scope_);
|
||||
},
|
||||
[](const ExtraFields<EventType::Backend>& i){},
|
||||
[](const auto&) { TORCH_INTERNAL_ASSERT(false); }),
|
||||
frame->extra_fields_);
|
||||
frame->finished_ = true;
|
||||
TORCH_INTERNAL_ASSERT(!frame->parent_.expired());
|
||||
frame = frame->parent_.lock();
|
||||
|
Reference in New Issue
Block a user