-
Notifications
You must be signed in to change notification settings - Fork 22.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make PyTorch code-base clang-tidy compliant #56892
Make PyTorch code-base clang-tidy compliant #56892
Conversation
💊 CI failures summary and remediationsAs of commit bb6a28a (more details on the Dr. CI page):
ci.pytorch.org: 1 failedThis comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Codecov Report
@@ Coverage Diff @@
## master #56892 +/- ##
=======================================
Coverage 77.20% 77.21%
=======================================
Files 1948 1948
Lines 193573 193572 -1
=======================================
+ Hits 149455 149467 +12
+ Misses 44118 44105 -13 |
31b3968
to
c970a5f
Compare
Summary: Attempts to call clang-tidy on any source file in `aten/src/ATen/cpu/native` would fail with series of ``` /Users/nshulga/git/pytorch-worktree/aten/src/ATen/native/cpu/Activation.cpp:637:1: warning: variable 'REGISTER_DISPATCH' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables] /Users/nshulga/git/pytorch-worktree/aten/src/ATen/native/cpu/Activation.cpp:638:1: error: C++ requires a type specifier for all declarations [clang-diagnostic-error] REGISTER_DISPATCH(log_sigmoid_backward_cpu_stub, &log_sigmoid_backward_cpu_kernel); ``` because those macros are only defined for cpu-arch specific compilation of above mentioned files. Fix this by introducing `map_filename` function that will map source file to its copy in `build` folder, run clang-tidy over the copy and than map it back Find it while working on #56892 Pull Request resolved: #57037 Reviewed By: walterddr Differential Revision: D28033760 Pulled By: malfet fbshipit-source-id: b67cd007000574ecc165ab4b285c0c102cbceadd
604cb3c
to
0448cd7
Compare
0448cd7
to
1595f90
Compare
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
@malfet has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Attempts to call clang-tidy on any source file in `aten/src/ATen/cpu/native` would fail with series of ``` /Users/nshulga/git/pytorch-worktree/aten/src/ATen/native/cpu/Activation.cpp:637:1: warning: variable 'REGISTER_DISPATCH' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables] /Users/nshulga/git/pytorch-worktree/aten/src/ATen/native/cpu/Activation.cpp:638:1: error: C++ requires a type specifier for all declarations [clang-diagnostic-error] REGISTER_DISPATCH(log_sigmoid_backward_cpu_stub, &log_sigmoid_backward_cpu_kernel); ``` because those macros are only defined for cpu-arch specific compilation of above mentioned files. Fix this by introducing `map_filename` function that will map source file to its copy in `build` folder, run clang-tidy over the copy and than map it back Find it while working on pytorch#56892 Pull Request resolved: pytorch#57037 Reviewed By: walterddr Differential Revision: D28033760 Pulled By: malfet fbshipit-source-id: b67cd007000574ecc165ab4b285c0c102cbceadd
Summary: This is an automatic change generated by the following script: ``` #!/usr/bin/env python3 from subprocess import check_output, check_call import os def get_compiled_files_list(): import json with open("build/compile_commands.json") as f: data = json.load(f) files = [os.path.relpath(node['file']) for node in data] for idx, fname in enumerate(files): if fname.startswith('build/') and fname.endswith('.DEFAULT.cpp'): files[idx] = fname[len('build/'):-len('.DEFAULT.cpp')] return files def run_clang_tidy(fname): check_call(["python3", "tools/clang_tidy.py", "-c", "build", "-x", fname,"-s"]) changes = check_output(["git", "ls-files", "-m"]) if len(changes) == 0: return check_call(["git", "commit","--all", "-m", f"NOLINT stubs for {fname}"]) def main(): git_files = check_output(["git", "ls-files"]).decode("ascii").split("\n") compiled_files = get_compiled_files_list() for idx, fname in enumerate(git_files): if fname not in compiled_files: continue if fname.startswith("caffe2/contrib/aten/"): continue print(f"[{idx}/{len(git_files)}] Processing {fname}") run_clang_tidy(fname) if __name__ == "__main__": main() ``` Pull Request resolved: pytorch#56892 Reviewed By: H-Huang Differential Revision: D27991944 Pulled By: malfet fbshipit-source-id: 5415e1eb2c1b34319a4f03024bfaa087007d7179
This is an automatic change generated by the following script: