Files
pytorch/torch/csrc/dynamo/cpp_shim.cpp
PyTorch MergeBot 783c5ba80a Revert "[PT2/Profiler] Add Context Info to Torch-Compiled Regions (#132765)"
This reverts commit 0b81f700aa7eb20d4b9f20e9627dd1208e50ea58.

Reverted https://github.com/pytorch/pytorch/pull/132765 on behalf of https://github.com/ezyang due to implementation is not correct, needs full rewrite ([comment](https://github.com/pytorch/pytorch/pull/132765#issuecomment-2364160452))
2024-09-20 17:10:27 +00:00

23 lines
551 B
C++

#include <torch/csrc/dynamo/cpp_shim.h>
#include <ATen/record_function.h>
struct _PytorchRecordFunctionState {
at::RecordFunction guard;
_PytorchRecordFunctionState() : guard(at::RecordScope::FUNCTION) {}
};
_PytorchRecordFunctionState* _pytorch_record_function_enter(const char* name) {
_PytorchRecordFunctionState* state = new _PytorchRecordFunctionState();
state->guard.before(name);
return state;
}
void _pytorch_record_function_exit(_PytorchRecordFunctionState* state) {
if (state == nullptr) {
return;
}
delete state;
}