mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Limit the option value of TORCH_SHOW_DISPATCH_TRACE (#136510)
It`s more convenient for user to enable or disable dispatch trace by setting TORCH_SHOW_DISPATCH_TRACE to 1 or 0, especially debug in IDE. Pull Request resolved: https://github.com/pytorch/pytorch/pull/136510 Approved by: https://github.com/shink, https://github.com/ezyang
This commit is contained in:
@ -17,8 +17,22 @@ TORCH_SDT_DEFINE_SEMAPHORE(operator_end)
|
||||
#endif
|
||||
|
||||
bool show_dispatch_trace() {
|
||||
static char const* temp = getenv("TORCH_SHOW_DISPATCH_TRACE");
|
||||
return temp != nullptr;
|
||||
static auto envar = std::getenv("TORCH_SHOW_DISPATCH_TRACE");
|
||||
|
||||
if (envar) {
|
||||
if (strcmp(envar, "0") == 0) {
|
||||
return false;
|
||||
}
|
||||
if (strcmp(envar, "1") == 0) {
|
||||
return true;
|
||||
}
|
||||
TORCH_WARN(
|
||||
"ignoring invalid value for TORCH_SHOW_DISPATCH_TRACE: ",
|
||||
envar,
|
||||
" valid values are 0 or 1.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static thread_local int64_t dispatch_trace_nesting_value_;
|
||||
|
Reference in New Issue
Block a user