Skip to content

Commit

Permalink
make valgrind_toggle and valgrind_supported_platform private (pytorch…
Browse files Browse the repository at this point in the history
  • Loading branch information
albanD authored Oct 23, 2020
1 parent a6e96b1 commit e85d494
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions torch/_C/__init__.pyi.in
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ def _log_api_usage_once(str) -> None: ... # LogAPIUsageOnceFromPython
def _demangle(str) -> str: ... # c10::demangle

# Defined in `valgrind.h` and `callgrind.h` respecitively.
def valgrind_supported_platform() -> _bool: ... # NVALGRIND
def valgrind_toggle() -> None: ... # CALLGRIND_TOGGLE_COLLECT
def _valgrind_supported_platform() -> _bool: ... # NVALGRIND
def _valgrind_toggle() -> None: ... # CALLGRIND_TOGGLE_COLLECT

has_openmp: _bool
has_mkl: _bool
Expand Down
4 changes: 2 additions & 2 deletions torch/csrc/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ Call this whenever a new thread is created in order to propagate values from
ASSERT_TRUE(set_module_attr("has_lapack", at::hasLAPACK() ? Py_True : Py_False));

py_module.def(
"valgrind_supported_platform", [](){
"_valgrind_supported_platform", [](){
#if defined(NVALGRIND)
return false;
#else
Expand All @@ -838,7 +838,7 @@ Call this whenever a new thread is created in order to propagate values from
);

py_module.def(
"valgrind_toggle", [](){
"_valgrind_toggle", [](){
#if defined(NVALGRIND)
TORCH_CHECK(false, "Valgrind is not supported.");
#else
Expand Down
2 changes: 0 additions & 2 deletions torch/overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ def get_ignored_functions() -> Set[Callable]:
torch.is_deterministic,
torch.set_deterministic,
torch.unify_type_list,
torch.valgrind_supported_platform,
torch.valgrind_toggle,
Tensor.__delitem__,
Tensor.__dir__,
Tensor.__getattribute__,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _diff(first: Tuple[FunctionCount, ...], second: Tuple[FunctionCount, ...]) -
class _ValgrindWrapper(object):
def __init__(self) -> None:
self._commands_available: Dict[str, bool] = {}
if torch._C.valgrind_supported_platform():
if torch._C._valgrind_supported_platform():
# Only bother checking on supported platforms.
for cmd in ("valgrind", "callgrind_control", "callgrind_annotate"):
self._commands_available[cmd] = not subprocess.run(
Expand All @@ -193,7 +193,7 @@ def __init__(self) -> None:
self._baseline_cache: Dict[Tuple[int, int], Tuple[Tuple[FunctionCount, ...], Tuple[FunctionCount, ...]]] = {}

def _validate(self) -> None:
if not torch._C.valgrind_supported_platform():
if not torch._C._valgrind_supported_platform():
raise OSError("Valgrind is not supported on this platform.")

missing_cmds = [cmd for cmd, available in self._commands_available.items() if not available]
Expand Down Expand Up @@ -444,13 +444,13 @@ def check_result(completed_process):
# =============================================================================
# == User code block ==========================================================
# =============================================================================
torch._C.valgrind_toggle()
torch._C._valgrind_toggle()
{blocked_stmt}
# Sleep is to allow the interpreter to catch up before we stop collecting in
# order to reduce jitter.
time.sleep(0.01)
torch._C.valgrind_toggle()
torch._C._valgrind_toggle()
""").strip().format(
indented_stmt=textwrap.indent(stmt, " " * 4),
blocked_stmt=blocked_stmt,
Expand Down

0 comments on commit e85d494

Please sign in to comment.