[profiler] remove redundant assert in record_function_ops (#33225)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/33225
This removes a redundant assert statement in `record_function_ops`. In
the else branch in question, we are guaranteed to have `current == &rec`, so
this assert will never fire.
Although, maybe we should add an assert failure when `current == &rec` since it
seems that `current` should always be profiler::record_function_exit.
ghstack-source-id: 98852219
Test Plan: Existing autograd profiler UTs past
Differential Revision: D19849145
fbshipit-source-id: 2014a0d3b9d11e5b64942a54e0fb45e21f46cfa2
diff --git a/torch/csrc/autograd/record_function_ops.cpp b/torch/csrc/autograd/record_function_ops.cpp
index 750cad6..95a8a65 100644
--- a/torch/csrc/autograd/record_function_ops.cpp
+++ b/torch/csrc/autograd/record_function_ops.cpp
@@ -4,6 +4,7 @@
namespace caffe2 {
// Required for cpp_custom_type_hack to work
+// NOLINTNEXTLINE(bugprone-exception-escape)
CAFFE_KNOWN_TYPE(torch::autograd::profiler::RecordFunction);
} // namespace caffe2
@@ -36,10 +37,9 @@
if (rec.active() && current) {
if (current != &rec) {
AT_ASSERT(current->parent() == &rec, "rec must be parent");
- AT_ASSERT(current->name() == StringView("profiler::_record_function_exit"));
+ AT_ASSERT(
+ current->name() == StringView("profiler::_record_function_exit"));
current->end();
- } else {
- AT_ASSERT(current == &rec, "rec must be active");
}
rec.end();
}