mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
More detailed description of benefits can be found at #41001. This is Intel's counterpart of NVidia’s NVTX (https://pytorch.org/docs/stable/autograd.html#torch.autograd.profiler.emit_nvtx). ITT is a functionality for labeling trace data during application execution across different Intel tools. For integrating Intel(R) VTune Profiler into Kineto, ITT needs to be integrated into PyTorch first. It works with both standalone VTune Profiler [(https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html](https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html)) and Kineto-integrated VTune functionality in the future. It works for both Intel CPU and Intel XPU devices. Pitch Add VTune Profiler's ITT API function calls to annotate PyTorch ops, as well as developer customized code scopes on CPU, like NVTX for NVidia GPU. This PR rebases the code changes at https://github.com/pytorch/pytorch/pull/61335 to the latest master branch. Usage example: ``` with torch.autograd.profiler.emit_itt(): for i in range(10): torch.itt.range_push('step_{}'.format(i)) model(input) torch.itt.range_pop() ``` cc @ilia-cher @robieta @chaekit @gdankel @bitfort @ngimel @orionr @nbcsm @guotuofeng @guyang3532 @gaoteng-git Pull Request resolved: https://github.com/pytorch/pytorch/pull/63289 Approved by: https://github.com/malfet
24 lines
651 B
C++
24 lines
651 B
C++
#include <c10/macros/Export.h>
|
|
#include <ittnotify.h>
|
|
|
|
namespace torch {
|
|
namespace profiler {
|
|
__itt_domain* _itt_domain = __itt_domain_create("PyTorch");
|
|
|
|
TORCH_API void itt_range_push(const char* msg) {
|
|
__itt_string_handle* hsMsg = __itt_string_handle_create(msg);
|
|
__itt_task_begin(_itt_domain, __itt_null, __itt_null, hsMsg);
|
|
}
|
|
|
|
TORCH_API void itt_range_pop() {
|
|
__itt_task_end(_itt_domain);
|
|
}
|
|
|
|
TORCH_API void itt_mark(const char* msg) {
|
|
__itt_string_handle* hsMsg = __itt_string_handle_create(msg);
|
|
__itt_task_begin(_itt_domain, __itt_null, __itt_null, hsMsg);
|
|
__itt_task_end(_itt_domain);
|
|
}
|
|
} // namespace profiler
|
|
} // namespace torch
|