pytorch/torch/profiler/python_tracer.py
Taylor Robie 9f2e2aa28b Revert "Revert "[Profiler] Move python tracing to unified event type (Part 2)""
This reverts commit 4305f8e9bd.

replace TEST_CUDA with torch.has_cuda

Pull Request resolved: https://github.com/pytorch/pytorch/pull/79173

Approved by: https://github.com/ezyang
2022-06-09 19:45:02 +00:00

20 lines
497 B
Python

import os
import site
import sys
import typing
import torch
def _prefix_regex() -> typing.List[str]:
raw_paths = (
site.getsitepackages() +
sys.path +
[site.getuserbase()] +
[site.getusersitepackages()] +
[os.path.dirname(os.path.dirname(torch.__file__))]
)
path_prefixes = sorted({os.path.abspath(i) for i in raw_paths}, reverse=True)
assert all(isinstance(i, str) for i in path_prefixes)
return [i + os.sep for i in path_prefixes]