mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE]: Merge startswith calls - rule PIE810 (#96754)
Merges startswith, endswith calls to into a single call that feeds in a tuple. Not only are these calls more readable, but it will be more efficient as it iterates through each string only once. Pull Request resolved: https://github.com/pytorch/pytorch/pull/96754 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
be4eaa69c2
commit
dd5e6e8553
@ -799,14 +799,14 @@ def preprocessor(
|
||||
f = m.group(1)
|
||||
dirpath, filename = os.path.split(f)
|
||||
if (
|
||||
f.startswith("ATen/cuda")
|
||||
or f.startswith("ATen/native/cuda")
|
||||
or f.startswith("ATen/native/nested/cuda")
|
||||
or f.startswith("ATen/native/quantized/cuda")
|
||||
or f.startswith("ATen/native/sparse/cuda")
|
||||
or f.startswith("ATen/native/transformers/cuda")
|
||||
or f.startswith("THC/")
|
||||
or (f.startswith("THC") and not f.startswith("THCP"))
|
||||
f.startswith(("ATen/cuda",
|
||||
"ATen/native/cuda",
|
||||
"ATen/native/nested/cuda",
|
||||
"ATen/native/quantized/cuda",
|
||||
"ATen/native/sparse/cuda",
|
||||
"ATen/native/transformers/cuda",
|
||||
"THC/")) or
|
||||
(f.startswith("THC") and not f.startswith("THCP"))
|
||||
):
|
||||
return templ.format(get_hip_file_path(m.group(1), is_pytorch_extension))
|
||||
# if filename is one of the files being hipified for this extension
|
||||
@ -858,7 +858,7 @@ def preprocessor(
|
||||
output_source = processKernelLaunches(output_source, stats)
|
||||
|
||||
# Replace std:: with non-std:: versions
|
||||
if (filepath.endswith(".cu") or filepath.endswith(".cuh")) and "PowKernel" not in filepath:
|
||||
if (filepath.endswith((".cu", ".cuh"))) and "PowKernel" not in filepath:
|
||||
output_source = replace_math_functions(output_source)
|
||||
|
||||
# Include header if device code is contained.
|
||||
|
Reference in New Issue
Block a user