From 5bcbbf537327f6e8328289c25a3a453a2444d984 Mon Sep 17 00:00:00 2001 From: Sam Estep Date: Tue, 30 Mar 2021 13:05:16 -0700 Subject: [PATCH] Lint trailing newlines (#54737) Summary: *Context:* https://github.com/pytorch/pytorch/issues/53406 added a lint for trailing whitespace at the ends of lines. However, in order to pass FB-internal lints, that PR also had to normalize the trailing newlines in four of the files it touched. This PR adds an OSS lint to normalize trailing newlines. The changes to the following files (made in 54847d0adb9be71be4979cead3d9d4c02160e4cd) are the only manually-written parts of this PR: - `.github/workflows/lint.yml` - `mypy-strict.ini` - `tools/README.md` - `tools/test/test_trailing_newlines.py` - `tools/trailing_newlines.py` I would have liked to make this just a shell one-liner like the other three similar lints, but nothing I could find quite fit the bill. Specifically, all the answers I tried from the following Stack Overflow questions were far too slow (at least a minute and a half to run on this entire repository): - [How to detect file ends in newline?](https://stackoverflow.com/q/38746) - [How do I find files that do not end with a newline/linefeed?](https://stackoverflow.com/q/4631068) - [How to list all files in the Git index without newline at end of file](https://stackoverflow.com/q/27624800) - [Linux - check if there is an empty line at the end of a file [duplicate]](https://stackoverflow.com/q/34943632) - [git ensure newline at end of each file](https://stackoverflow.com/q/57770972) To avoid giving false positives during the few days after this PR is merged, we should probably only merge it after https://github.com/pytorch/pytorch/issues/54967. Pull Request resolved: https://github.com/pytorch/pytorch/pull/54737 Test Plan: Running the shell script from the "Ensure correct trailing newlines" step in the `quick-checks` job of `.github/workflows/lint.yml` should print no output and exit in a fraction of a second with a status of 0. That was not the case prior to this PR, as shown by this failing GHA workflow run on an earlier draft of this PR: - https://github.com/pytorch/pytorch/runs/2197446987?check_suite_focus=true In contrast, this run (after correcting the trailing newlines in this PR) succeeded: - https://github.com/pytorch/pytorch/pull/54737/checks?check_run_id=2197553241 To unit-test `tools/trailing_newlines.py` itself (this is run as part of our "Test tools" GitHub Actions workflow): ``` python tools/test/test_trailing_newlines.py ``` Reviewed By: malfet Differential Revision: D27409736 Pulled By: samestep fbshipit-source-id: 46f565227046b39f68349bbd5633105b2d2e9b19 --- .circleci/windows-jni/include/jni.h | 1 - .github/workflows/lint.yml | 3 ++ .../pytorch/perf_test/test_cpu_speed_torch.sh | 1 - .../perf_test/test_cpu_speed_torch_tensor.sh | 1 - .../app/src/main/res/layout/activity_main.xml | 2 +- aten/src/ATen/NumericUtils.h | 1 - .../vec256/vsx/vec256_complex_double_vsx.h | 1 - aten/src/ATen/cpu/vec256/vsx/vsx_helpers.h | 1 - aten/src/ATen/cudnn/cudnn-wrapper.h | 1 - aten/src/ATen/div_rtn.h | 1 - aten/src/ATen/native/Cross.h | 1 - aten/src/ATen/native/batch_norm.h | 1 - aten/src/ATen/native/cpu/CrossKernel.cpp | 1 - aten/src/ATen/native/cuda/CrossKernel.cu | 1 - .../native/cuda/EmbeddingBackwardKernel.cuh | 2 +- .../native/quantized/cpu/kernels/README.md | 2 +- .../quantized/cpu/qnnpack/CONTRIBUTING.md | 2 +- aten/src/ATen/test/NamedTensor_test.cpp | 2 - aten/src/ATen/test/cuda_complex_math_test.cu | 1 - aten/src/ATen/test/pow_test.cpp | 1 - .../generated/THCTensorMathCompareTBool.cu | 1 - .../generated/THCTensorMathCompareTByte.cu | 1 - .../generated/THCTensorMathCompareTChar.cu | 1 - .../generated/THCTensorMathCompareTDouble.cu | 1 - .../generated/THCTensorMathCompareTFloat.cu | 1 - .../generated/THCTensorMathCompareTHalf.cu | 1 - .../THC/generated/THCTensorMathCompareTInt.cu | 1 - .../generated/THCTensorMathCompareTLong.cu | 1 - .../generated/THCTensorMathCompareTShort.cu | 1 - benchmarks/README.md | 1 - benchmarks/fastrnns/README.md | 1 - c10/util/Optional.cpp | 2 +- c10/util/Unicode.cpp | 2 +- caffe2/core/common_test.cc | 2 - .../core/nomnigraph/tests/AlgorithmsTest.cc | 1 - caffe2/onnx/device.cc | 1 - caffe2/operators/roi_align_op.cc | 1 - caffe2/opt/optimizer.cc | 1 - caffe2/python/CMakeLists.txt | 1 - caffe2/python/convert.py | 5 -- caffe2/python/fakelowp/init_shared_libs.py | 1 - caffe2/python/onnx/README.md | 1 - caffe2/python/onnx/backend_cpp_rep.py | 1 - caffe2/python/onnx/test_onnxifi.py | 2 - caffe2/python/onnx/tests/__init__.py | 4 -- caffe2/python/onnx/tests/test_utils.py | 1 - caffe2/python/operator_test/mean_op_test.py | 1 - caffe2/python/rnn/__init__.py | 5 -- .../serialized_test/SerializedTestCoverage.md | 1 - caffe2/python/trt/data/class_labels.txt | 2 +- caffe2/python/trt/test_trt.py | 2 - caffe2/python/trt/transform.py | 1 - caffe2/utils/simple_queue_test.cc | 2 - cmake/Modules/FindAtlas.cmake | 1 - cmake/Modules/FindHiredis.cmake | 1 - cmake/Modules/FindNumPy.cmake | 1 - cmake/Modules/FindNuma.cmake | 1 - cmake/Modules/FindOpenBLAS.cmake | 1 - cmake/Modules/FindRocksDB.cmake | 1 - cmake/Modules/FindSnappy.cmake | 1 - cmake/Modules/FindVSX.cmake | 1 - .../upstream/FindCUDA/parse_cubin.cmake | 2 - cmake/public/gflags.cmake | 1 - cmake/public/glog.cmake | 1 - cmake/public/utils.cmake | 1 - docs/caffe2/DOXYGEN.md | 1 - docs/cpp/Makefile | 1 - docs/source/community/persons_of_interest.rst | 3 -- docs/source/dlpack.rst | 1 - docs/source/jit_builtin_functions.rst | 1 - .../cpu_threading_torchscript_inference.svg | 2 +- docs/source/notes/randomness.rst | 2 - docs/source/special.rst | 2 +- docs/source/storage.rst | 1 - docs/source/torch.nn.intrinsic.quantized.rst | 2 - docs/source/torch.nn.qat.rst | 3 -- docs/source/torch.quantization.rst | 1 - ios/TestApp/.clang-format | 2 +- ios/TestApp/Gemfile | 2 +- .../AppIcon.appiconset/Contents.json | 2 +- .../TestApp/Assets.xcassets/Contents.json | 2 +- ios/TestApp/fastlane/Fastfile | 2 +- modules/observers/CMakeLists.txt | 1 - mypy-strict.ini | 2 + scripts/apache_header.txt | 1 - scripts/apache_python.txt | 1 - scripts/diagnose_protobuf.py | 4 -- scripts/release_notes/common.py | 1 - scripts/xcode_build.rb | 1 - test/benchmark_utils/callgrind_artifacts.json | 2 +- test/cpp/api/dataloader.cpp | 2 +- test/cpp/api/init_baseline.h | 2 +- test/optim/test.lua | 1 - tools/README.md | 4 ++ .../autograd/templates/InplaceOrViewType.cpp | 1 - .../linux64/clang-format-linux64 | 2 +- .../clang_format_hash/mac/clang-format-mojave | 2 +- tools/test/test_trailing_newlines.py | 49 +++++++++++++++++++ tools/trailing_newlines.py | 37 ++++++++++++++ tools/update_disabled_tests.sh | 2 +- torch/_C/_cudnn.pyi | 2 +- torch/_C/_functions.pyi | 2 +- torch/_C/_nn.pyi.in | 2 +- torch/csrc/deploy/CMakeLists.txt | 1 - .../source_range_serialization_impl.h | 2 +- torch/csrc/python_dimname.cpp | 1 - torch/csrc/python_dimname.h | 1 - torch/csrc/python_headers.h | 1 - torch/deploy.h | 2 +- torch/optim/_multi_tensor/__init__.pyi | 2 +- torch/optim/_multi_tensor/adadelta.pyi | 2 +- 111 files changed, 122 insertions(+), 132 deletions(-) create mode 100644 tools/test/test_trailing_newlines.py create mode 100755 tools/trailing_newlines.py diff --git a/.circleci/windows-jni/include/jni.h b/.circleci/windows-jni/include/jni.h index f793148c1df0..1fdc6f3ad69d 100644 --- a/.circleci/windows-jni/include/jni.h +++ b/.circleci/windows-jni/include/jni.h @@ -1129,4 +1129,3 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved); #define JNI_ABORT 2 /* free buffer w/o copying back */ #endif /* JNI_H_ */ - diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d1c9d91148e9..dd1197b4adba 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,6 +30,9 @@ jobs: rm -r "shellcheck-${scversion}" shellcheck --version .jenkins/run-shellcheck.sh + - name: Ensure correct trailing newlines + run: | + (! git grep -Il '' -- . ':(exclude)**/contrib/**' ':(exclude)third_party' ':(exclude)**.expect' | tools/trailing_newlines.py || (echo "The above files do not have correct trailing newlines; please normalize them"; false)) - name: Ensure no trailing spaces run: | (! git grep -I -no ' $' -- . ':(exclude)**/contrib/**' ':(exclude)third_party' || (echo "The above files have trailing spaces; please remove them"; false)) diff --git a/.jenkins/pytorch/perf_test/test_cpu_speed_torch.sh b/.jenkins/pytorch/perf_test/test_cpu_speed_torch.sh index e805389aeaa8..b8f980134142 100644 --- a/.jenkins/pytorch/perf_test/test_cpu_speed_torch.sh +++ b/.jenkins/pytorch/perf_test/test_cpu_speed_torch.sh @@ -27,4 +27,3 @@ test_cpu_speed_torch () { if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then run_test test_cpu_speed_torch "$@" fi - diff --git a/.jenkins/pytorch/perf_test/test_cpu_speed_torch_tensor.sh b/.jenkins/pytorch/perf_test/test_cpu_speed_torch_tensor.sh index 6dc5a7b200b4..c0226206075c 100644 --- a/.jenkins/pytorch/perf_test/test_cpu_speed_torch_tensor.sh +++ b/.jenkins/pytorch/perf_test/test_cpu_speed_torch_tensor.sh @@ -27,4 +27,3 @@ test_cpu_speed_torch_tensor () { if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then run_test test_cpu_speed_torch_tensor "$@" fi - diff --git a/android/test_app/app/src/main/res/layout/activity_main.xml b/android/test_app/app/src/main/res/layout/activity_main.xml index c0939ebc0ebc..556839a994c5 100644 --- a/android/test_app/app/src/main/res/layout/activity_main.xml +++ b/android/test_app/app/src/main/res/layout/activity_main.xml @@ -14,4 +14,4 @@ android:background="@android:color/black" android:textColor="@android:color/white" /> - \ No newline at end of file + diff --git a/aten/src/ATen/NumericUtils.h b/aten/src/ATen/NumericUtils.h index e6726602bbd5..ecac8cfe3dce 100644 --- a/aten/src/ATen/NumericUtils.h +++ b/aten/src/ATen/NumericUtils.h @@ -105,4 +105,3 @@ C10_HOST_DEVICE inline double tan(double x) { } } // namespace at - diff --git a/aten/src/ATen/cpu/vec256/vsx/vec256_complex_double_vsx.h b/aten/src/ATen/cpu/vec256/vsx/vec256_complex_double_vsx.h index 861335861123..d4f76197c6e4 100644 --- a/aten/src/ATen/cpu/vec256/vsx/vec256_complex_double_vsx.h +++ b/aten/src/ATen/cpu/vec256/vsx/vec256_complex_double_vsx.h @@ -594,4 +594,3 @@ Vec256 inline minimum( } // namespace } // namespace vec256 } // namespace at - diff --git a/aten/src/ATen/cpu/vec256/vsx/vsx_helpers.h b/aten/src/ATen/cpu/vec256/vsx/vsx_helpers.h index 61a572e1abcc..a9ccf5543bae 100644 --- a/aten/src/ATen/cpu/vec256/vsx/vsx_helpers.h +++ b/aten/src/ATen/cpu/vec256/vsx/vsx_helpers.h @@ -386,4 +386,3 @@ const vfloat64 vd_pi_2 = vfloat64{M_PI / 2.0, 0.0}; } // namespace } // namespace vec256 } // namespace at - diff --git a/aten/src/ATen/cudnn/cudnn-wrapper.h b/aten/src/ATen/cudnn/cudnn-wrapper.h index 66a926fe577f..0358b15c117f 100644 --- a/aten/src/ATen/cudnn/cudnn-wrapper.h +++ b/aten/src/ATen/cudnn/cudnn-wrapper.h @@ -13,4 +13,3 @@ #undef STRINGIFY #undef STRING - diff --git a/aten/src/ATen/div_rtn.h b/aten/src/ATen/div_rtn.h index 7b6beec4b063..f9cafb8ed1a7 100644 --- a/aten/src/ATen/div_rtn.h +++ b/aten/src/ATen/div_rtn.h @@ -8,4 +8,3 @@ static inline T div_rtn(T x, T y) { if ((r!=0) && ((r<0) != (y<0))) --q; return q; } - diff --git a/aten/src/ATen/native/Cross.h b/aten/src/ATen/native/Cross.h index 35f9886b2b08..5517f601e6af 100644 --- a/aten/src/ATen/native/Cross.h +++ b/aten/src/ATen/native/Cross.h @@ -10,4 +10,3 @@ using cross_fn = void(*)(Tensor&, const Tensor&, const Tensor&, const int64_t d) DECLARE_DISPATCH(cross_fn, cross_stub); }} // namespace at::native - diff --git a/aten/src/ATen/native/batch_norm.h b/aten/src/ATen/native/batch_norm.h index 9ff05b70ccd4..bd78a5b7ebe2 100644 --- a/aten/src/ATen/native/batch_norm.h +++ b/aten/src/ATen/native/batch_norm.h @@ -15,4 +15,3 @@ DECLARE_DISPATCH(batch_norm_fn, batch_norm_cpu_inference_contiguous_stub); } // namespace native } // namespace at - diff --git a/aten/src/ATen/native/cpu/CrossKernel.cpp b/aten/src/ATen/native/cpu/CrossKernel.cpp index 0d405447bc1a..55e02295a9f8 100644 --- a/aten/src/ATen/native/cpu/CrossKernel.cpp +++ b/aten/src/ATen/native/cpu/CrossKernel.cpp @@ -75,4 +75,3 @@ static void cross_kernel_impl(Tensor& result, const Tensor& a, const Tensor& b, REGISTER_DISPATCH(cross_stub, &cross_kernel_impl); }} // namespace at::native - diff --git a/aten/src/ATen/native/cuda/CrossKernel.cu b/aten/src/ATen/native/cuda/CrossKernel.cu index d03ee0009cd6..31fd2a90887d 100644 --- a/aten/src/ATen/native/cuda/CrossKernel.cu +++ b/aten/src/ATen/native/cuda/CrossKernel.cu @@ -12,4 +12,3 @@ void cross_kernel_impl(Tensor& result, const Tensor& x1, const Tensor& x2, const REGISTER_DISPATCH(cross_stub, &cross_kernel_impl); }} - diff --git a/aten/src/ATen/native/cuda/EmbeddingBackwardKernel.cuh b/aten/src/ATen/native/cuda/EmbeddingBackwardKernel.cuh index e483550dc1ed..960b28afb8c7 100644 --- a/aten/src/ATen/native/cuda/EmbeddingBackwardKernel.cuh +++ b/aten/src/ATen/native/cuda/EmbeddingBackwardKernel.cuh @@ -33,4 +33,4 @@ Tensor embedding_backward_cuda_kernel( const Tensor &bag_size = Tensor(), const Tensor &per_sample_weights = Tensor()); -}} \ No newline at end of file +}} diff --git a/aten/src/ATen/native/quantized/cpu/kernels/README.md b/aten/src/ATen/native/quantized/cpu/kernels/README.md index dc3f6cfe14d1..c3685ac9d699 100644 --- a/aten/src/ATen/native/quantized/cpu/kernels/README.md +++ b/aten/src/ATen/native/quantized/cpu/kernels/README.md @@ -13,4 +13,4 @@ IS THE CASE CAN LEAD TO HARD-TO-DEBUG ODR VIOLATIONS. - **Make sure different variants of the code (AVX, AVX2) are tested!** There are build variants that do things like have NO AVX and NO AVX2 in - CI. Make sure they work! \ No newline at end of file + CI. Make sure they work! diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/CONTRIBUTING.md b/aten/src/ATen/native/quantized/cpu/qnnpack/CONTRIBUTING.md index cd6b1221a071..9a17a037b694 100644 --- a/aten/src/ATen/native/quantized/cpu/qnnpack/CONTRIBUTING.md +++ b/aten/src/ATen/native/quantized/cpu/qnnpack/CONTRIBUTING.md @@ -31,4 +31,4 @@ outlined on that page and do not file a public issue. ## License By contributing to QNNPACK, you agree that your contributions will be licensed -under the LICENSE file in the root directory of this source tree. \ No newline at end of file +under the LICENSE file in the root directory of this source tree. diff --git a/aten/src/ATen/test/NamedTensor_test.cpp b/aten/src/ATen/test/NamedTensor_test.cpp index 0872d9265946..d1468ac0680b 100644 --- a/aten/src/ATen/test/NamedTensor_test.cpp +++ b/aten/src/ATen/test/NamedTensor_test.cpp @@ -233,5 +233,3 @@ TEST(NamedTensorTest, TensorNamesCheckUnique) { ASSERT_THROW(tensornames.checkUnique("op_name"), c10::Error); } } - - diff --git a/aten/src/ATen/test/cuda_complex_math_test.cu b/aten/src/ATen/test/cuda_complex_math_test.cu index fe444a78e7bc..ddc60dfd2ab2 100644 --- a/aten/src/ATen/test/cuda_complex_math_test.cu +++ b/aten/src/ATen/test/cuda_complex_math_test.cu @@ -35,4 +35,3 @@ __global__ void CUDA##a##b() #define C10_DEFINE_TEST(a, b) TEST(a##Host, b) #define C10_ASSERT_NEAR(a, b, tol) ASSERT_NEAR(a, b, tol) #include - diff --git a/aten/src/ATen/test/pow_test.cpp b/aten/src/ATen/test/pow_test.cpp index c865f050dc48..948841ae36ad 100644 --- a/aten/src/ATen/test/pow_test.cpp +++ b/aten/src/ATen/test/pow_test.cpp @@ -364,4 +364,3 @@ TEST(PowTest, TestIntegralPow) { test_inverse(longs); test_inverse(ints); } - diff --git a/aten/src/THC/generated/THCTensorMathCompareTBool.cu b/aten/src/THC/generated/THCTensorMathCompareTBool.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTBool.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTBool.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTByte.cu b/aten/src/THC/generated/THCTensorMathCompareTByte.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTByte.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTByte.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTChar.cu b/aten/src/THC/generated/THCTensorMathCompareTChar.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTChar.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTChar.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTDouble.cu b/aten/src/THC/generated/THCTensorMathCompareTDouble.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTDouble.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTDouble.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTFloat.cu b/aten/src/THC/generated/THCTensorMathCompareTFloat.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTFloat.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTFloat.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTHalf.cu b/aten/src/THC/generated/THCTensorMathCompareTHalf.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTHalf.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTHalf.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTInt.cu b/aten/src/THC/generated/THCTensorMathCompareTInt.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTInt.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTInt.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTLong.cu b/aten/src/THC/generated/THCTensorMathCompareTLong.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTLong.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTLong.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/aten/src/THC/generated/THCTensorMathCompareTShort.cu b/aten/src/THC/generated/THCTensorMathCompareTShort.cu index 17e2a4f72a35..9624e950fe13 100644 --- a/aten/src/THC/generated/THCTensorMathCompareTShort.cu +++ b/aten/src/THC/generated/THCTensorMathCompareTShort.cu @@ -1,3 +1,2 @@ #include #include - diff --git a/benchmarks/README.md b/benchmarks/README.md index 56b3159e5ea0..3665818ab2d4 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -26,4 +26,3 @@ python -c "import torch; print(torch.__version__)" Please refer to each subfolder to discover each benchmark suite * [Fast RNNs benchmarks](fastrnns/README.md) - diff --git a/benchmarks/fastrnns/README.md b/benchmarks/fastrnns/README.md index 830190e28332..7cd51d4356c7 100644 --- a/benchmarks/fastrnns/README.md +++ b/benchmarks/fastrnns/README.md @@ -39,4 +39,3 @@ you can also specify the models to generate nvprof files separately: Use Linux for the most accurate timing. A lot of these tests only run on CUDA. - diff --git a/c10/util/Optional.cpp b/c10/util/Optional.cpp index dd91391719b4..ce2ee24e35dd 100644 --- a/c10/util/Optional.cpp +++ b/c10/util/Optional.cpp @@ -7,4 +7,4 @@ #if (!defined(__CUDA_ARCH__) || !defined(CUDA_VERSION) || CUDA_VERSION > 9200) static_assert(C10_IS_TRIVIALLY_COPYABLE(c10::optional), "c10::optional should be trivially copyable"); static_assert(C10_IS_TRIVIALLY_COPYABLE(c10::optional), "c10::optional should be trivially copyable"); -#endif \ No newline at end of file +#endif diff --git a/c10/util/Unicode.cpp b/c10/util/Unicode.cpp index e6d41bc73186..1c7eefc57b5a 100644 --- a/c10/util/Unicode.cpp +++ b/c10/util/Unicode.cpp @@ -46,4 +46,4 @@ std::string u16u8(const std::wstring& wstr) { return str; } #endif -} // namespace c10 \ No newline at end of file +} // namespace c10 diff --git a/caffe2/core/common_test.cc b/caffe2/core/common_test.cc index 4e9b65828a81..7de0a7370990 100644 --- a/caffe2/core/common_test.cc +++ b/caffe2/core/common_test.cc @@ -41,5 +41,3 @@ TEST(CommonTest, TestStod) { #endif // __ANDROID__ } // namespace caffe2 - - diff --git a/caffe2/core/nomnigraph/tests/AlgorithmsTest.cc b/caffe2/core/nomnigraph/tests/AlgorithmsTest.cc index e0de91bb2ade..65f8ad5f88c9 100644 --- a/caffe2/core/nomnigraph/tests/AlgorithmsTest.cc +++ b/caffe2/core/nomnigraph/tests/AlgorithmsTest.cc @@ -123,4 +123,3 @@ TEST(Subgraph, InduceEdgesCycle) { EXPECT_TRUE(sg.hasEdge(edge)); } } - diff --git a/caffe2/onnx/device.cc b/caffe2/onnx/device.cc index 7808c54f307a..9dd2d1c76c37 100644 --- a/caffe2/onnx/device.cc +++ b/caffe2/onnx/device.cc @@ -15,4 +15,3 @@ Device::Device(const std::string &spec) { device_id = atoi(spec.substr(pos + 1).c_str()); } }} - diff --git a/caffe2/operators/roi_align_op.cc b/caffe2/operators/roi_align_op.cc index 02120137465f..2367e525b93d 100644 --- a/caffe2/operators/roi_align_op.cc +++ b/caffe2/operators/roi_align_op.cc @@ -312,4 +312,3 @@ C10_EXPORT_CAFFE2_OP_TO_C10_CPU( " bool aligned" ") -> Tensor", caffe2::RoIAlignCPUOp); - diff --git a/caffe2/opt/optimizer.cc b/caffe2/opt/optimizer.cc index 2e707a13828f..72de6d861598 100644 --- a/caffe2/opt/optimizer.cc +++ b/caffe2/opt/optimizer.cc @@ -45,4 +45,3 @@ NetDef optimize(NetDef net, int level) { } // namespace opt } // namespace caffe2 - diff --git a/caffe2/python/CMakeLists.txt b/caffe2/python/CMakeLists.txt index ee910e831e8b..373a4fff86b6 100644 --- a/caffe2/python/CMakeLists.txt +++ b/caffe2/python/CMakeLists.txt @@ -33,4 +33,3 @@ prepend(Caffe2_HIP_PYTHON_SRCS ${CMAKE_CURRENT_SOURCE_DIR} ${Caffe2_HIP_PYTHON_S set(Caffe2_CPU_PYTHON_SRCS ${Caffe2_CPU_PYTHON_SRCS} PARENT_SCOPE) set(Caffe2_GPU_PYTHON_SRCS ${Caffe2_GPU_PYTHON_SRCS} PARENT_SCOPE) set(Caffe2_HIP_PYTHON_SRCS ${Caffe2_HIP_PYTHON_SRCS} PARENT_SCOPE) - diff --git a/caffe2/python/convert.py b/caffe2/python/convert.py index b4b37811de10..b3b5822c46ca 100644 --- a/caffe2/python/convert.py +++ b/caffe2/python/convert.py @@ -1,7 +1,2 @@ ## @package workspace # Module caffe2.python.workspace - - - - - diff --git a/caffe2/python/fakelowp/init_shared_libs.py b/caffe2/python/fakelowp/init_shared_libs.py index 2a98de4571aa..889b2bcab520 100644 --- a/caffe2/python/fakelowp/init_shared_libs.py +++ b/caffe2/python/fakelowp/init_shared_libs.py @@ -7,4 +7,3 @@ if 'OSS_ONNXIFI_LIB' in os.environ: lib = os.environ['OSS_ONNXIFI_LIB'] print("Loading ONNXIFI lib: ".format(lib)) ctypes.CDLL(lib, ctypes.RTLD_GLOBAL) - diff --git a/caffe2/python/onnx/README.md b/caffe2/python/onnx/README.md index 441914fb16b2..444951bf684a 100644 --- a/caffe2/python/onnx/README.md +++ b/caffe2/python/onnx/README.md @@ -51,4 +51,3 @@ pip install -e caffe2/ # License [MIT License](LICENSE) - diff --git a/caffe2/python/onnx/backend_cpp_rep.py b/caffe2/python/onnx/backend_cpp_rep.py index 4a75068cfd03..322e6c2e2894 100644 --- a/caffe2/python/onnx/backend_cpp_rep.py +++ b/caffe2/python/onnx/backend_cpp_rep.py @@ -49,4 +49,3 @@ class Caffe2CppRep(BackendRep): # single input output_values = self.__core.run([inputs]) return namedtupledict('Outputs', self.__external_outputs)(*output_values) - diff --git a/caffe2/python/onnx/test_onnxifi.py b/caffe2/python/onnx/test_onnxifi.py index 4316149d5bf6..73a120616985 100644 --- a/caffe2/python/onnx/test_onnxifi.py +++ b/caffe2/python/onnx/test_onnxifi.py @@ -197,5 +197,3 @@ class OnnxifiTransformTest(TestCase): output_values = [workspace.FetchBlob(name) for name in net_outputs] Y_trt = namedtupledict('Outputs', net_outputs)(*output_values) np.testing.assert_allclose(Y_c2, Y_trt, rtol=1e-3) - - diff --git a/caffe2/python/onnx/tests/__init__.py b/caffe2/python/onnx/tests/__init__.py index fd40910d9e70..e69de29bb2d1 100644 --- a/caffe2/python/onnx/tests/__init__.py +++ b/caffe2/python/onnx/tests/__init__.py @@ -1,4 +0,0 @@ - - - - diff --git a/caffe2/python/onnx/tests/test_utils.py b/caffe2/python/onnx/tests/test_utils.py index bebfc1012957..8585624e1af8 100644 --- a/caffe2/python/onnx/tests/test_utils.py +++ b/caffe2/python/onnx/tests/test_utils.py @@ -27,4 +27,3 @@ class TestCase(unittest.TestCase): if hasattr(self, name): raise ValueError('Duplicated test name: {}'.format(name)) setattr(self, name, test_func) - diff --git a/caffe2/python/operator_test/mean_op_test.py b/caffe2/python/operator_test/mean_op_test.py index ee2c6fc8fbf7..a549426170ce 100644 --- a/caffe2/python/operator_test/mean_op_test.py +++ b/caffe2/python/operator_test/mean_op_test.py @@ -60,4 +60,3 @@ class TestMean(serial.SerializedTestCase): if __name__ == "__main__": unittest.main() - diff --git a/caffe2/python/rnn/__init__.py b/caffe2/python/rnn/__init__.py index 3f2ff2d6cc8f..e69de29bb2d1 100644 --- a/caffe2/python/rnn/__init__.py +++ b/caffe2/python/rnn/__init__.py @@ -1,5 +0,0 @@ - - - - - diff --git a/caffe2/python/serialized_test/SerializedTestCoverage.md b/caffe2/python/serialized_test/SerializedTestCoverage.md index f98dad595b88..4e61b65ec44d 100644 --- a/caffe2/python/serialized_test/SerializedTestCoverage.md +++ b/caffe2/python/serialized_test/SerializedTestCoverage.md @@ -876,4 +876,3 @@ Serialized tests have covered 220/852 (25.8%) operators * LengthsSumFakeFp16 * SparseLengthsMax - diff --git a/caffe2/python/trt/data/class_labels.txt b/caffe2/python/trt/data/class_labels.txt index 888d6f51dd77..f40829ed0fc3 100644 --- a/caffe2/python/trt/data/class_labels.txt +++ b/caffe2/python/trt/data/class_labels.txt @@ -997,4 +997,4 @@ earthstar hen-of-the-woods bolete ear -toilet tissue \ No newline at end of file +toilet tissue diff --git a/caffe2/python/trt/test_trt.py b/caffe2/python/trt/test_trt.py index 2782cca7c13f..6f9426d6a93a 100644 --- a/caffe2/python/trt/test_trt.py +++ b/caffe2/python/trt/test_trt.py @@ -277,5 +277,3 @@ class TensorRTTransformTest(TestCase): output_values = [workspace.FetchBlob(name) for name in net_outputs] Y_trt = namedtupledict('Outputs', net_outputs)(*output_values) np.testing.assert_allclose(Y_c2, Y_trt, rtol=1e-3) - - diff --git a/caffe2/python/trt/transform.py b/caffe2/python/trt/transform.py index 1b201007daab..0e304ca4fae3 100644 --- a/caffe2/python/trt/transform.py +++ b/caffe2/python/trt/transform.py @@ -106,4 +106,3 @@ def transform_caffe2_net( pred_net_cut = caffe2_pb2.NetDef() pred_net_cut.ParseFromString(pred_net_str) return pred_net_cut - diff --git a/caffe2/utils/simple_queue_test.cc b/caffe2/utils/simple_queue_test.cc index d0cf24acbf25..f9d2fa801b60 100644 --- a/caffe2/utils/simple_queue_test.cc +++ b/caffe2/utils/simple_queue_test.cc @@ -68,5 +68,3 @@ TEST(SimpleQueueDeathTest, CannotAddAfterQueueFinished) { } // namespace caffe2 - - diff --git a/cmake/Modules/FindAtlas.cmake b/cmake/Modules/FindAtlas.cmake index 9c665a47bd58..efacda1e26ad 100644 --- a/cmake/Modules/FindAtlas.cmake +++ b/cmake/Modules/FindAtlas.cmake @@ -49,4 +49,3 @@ if(ATLAS_FOUND) message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})") endif(ATLAS_FOUND) - diff --git a/cmake/Modules/FindHiredis.cmake b/cmake/Modules/FindHiredis.cmake index b9cb69b69a8d..f1389ded5868 100644 --- a/cmake/Modules/FindHiredis.cmake +++ b/cmake/Modules/FindHiredis.cmake @@ -21,4 +21,3 @@ if(HIREDIS_FOUND) message(STATUS "Found Hiredis (include: ${Hiredis_INCLUDE_DIR}, library: ${Hiredis_LIBRARIES})") mark_as_advanced(Hiredis_INCLUDE_DIR Hiredis_LIBRARIES) endif() - diff --git a/cmake/Modules/FindNumPy.cmake b/cmake/Modules/FindNumPy.cmake index a671494cabab..b1b93c772bba 100644 --- a/cmake/Modules/FindNumPy.cmake +++ b/cmake/Modules/FindNumPy.cmake @@ -55,4 +55,3 @@ if(NUMPY_FOUND) endif() caffe_clear_vars(__result __output __error_value __values __ver_check __error_value) - diff --git a/cmake/Modules/FindNuma.cmake b/cmake/Modules/FindNuma.cmake index 63fbe9014c16..b27b646e8a9a 100644 --- a/cmake/Modules/FindNuma.cmake +++ b/cmake/Modules/FindNuma.cmake @@ -26,4 +26,3 @@ if(NUMA_FOUND) "Found Numa (include: ${Numa_INCLUDE_DIR}, library: ${Numa_LIBRARIES})") mark_as_advanced(Numa_INCLUDE_DIR Numa_LIBRARIES) endif() - diff --git a/cmake/Modules/FindOpenBLAS.cmake b/cmake/Modules/FindOpenBLAS.cmake index be9e713d16f5..c909ace0a176 100644 --- a/cmake/Modules/FindOpenBLAS.cmake +++ b/cmake/Modules/FindOpenBLAS.cmake @@ -63,4 +63,3 @@ MARK_AS_ADVANCED( OpenBLAS_LIB OpenBLAS ) - diff --git a/cmake/Modules/FindRocksDB.cmake b/cmake/Modules/FindRocksDB.cmake index e33bcce2f85f..ef7f3b5f94b3 100644 --- a/cmake/Modules/FindRocksDB.cmake +++ b/cmake/Modules/FindRocksDB.cmake @@ -21,4 +21,3 @@ if(ROCKSDB_FOUND) message(STATUS "Found RocksDB (include: ${RocksDB_INCLUDE_DIR}, library: ${RocksDB_LIBRARIES})") mark_as_advanced(RocksDB_INCLUDE_DIR RocksDB_LIBRARIES) endif() - diff --git a/cmake/Modules/FindSnappy.cmake b/cmake/Modules/FindSnappy.cmake index 77fd32b85a71..97219e85075a 100644 --- a/cmake/Modules/FindSnappy.cmake +++ b/cmake/Modules/FindSnappy.cmake @@ -24,4 +24,3 @@ if(SNAPPY_FOUND) SNAPPY_VERION_LINES SNAPPY_MAJOR SNAPPY_MINOR SNAPPY_PATCHLEVEL) set(Snappy_VERSION "${SNAPPY_MAJOR}.${SNAPPY_MINOR}.${SNAPPY_PATCHLEVEL}") endif() - diff --git a/cmake/Modules/FindVSX.cmake b/cmake/Modules/FindVSX.cmake index 64f67ceeb0e3..304b3c90b5b4 100644 --- a/cmake/Modules/FindVSX.cmake +++ b/cmake/Modules/FindVSX.cmake @@ -32,4 +32,3 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux") endif() message("-- ") endif() - diff --git a/cmake/Modules_CUDA_fix/upstream/FindCUDA/parse_cubin.cmake b/cmake/Modules_CUDA_fix/upstream/FindCUDA/parse_cubin.cmake index 626c8a2e47d3..25ceb49f3dd8 100644 --- a/cmake/Modules_CUDA_fix/upstream/FindCUDA/parse_cubin.cmake +++ b/cmake/Modules_CUDA_fix/upstream/FindCUDA/parse_cubin.cmake @@ -107,5 +107,3 @@ if (NOT "${file_text}" STREQUAL "") else() # message("FOUND NO DEPENDS") endif() - - diff --git a/cmake/public/gflags.cmake b/cmake/public/gflags.cmake index a030fdd7d429..186cda1a909a 100644 --- a/cmake/public/gflags.cmake +++ b/cmake/public/gflags.cmake @@ -81,4 +81,3 @@ if(NOT TARGET gflags) "Caffe2 or a Caffe2 dependent library, the next warning / error will " "give you more info.") endif() - diff --git a/cmake/public/glog.cmake b/cmake/public/glog.cmake index a067c8dc7875..bb03e81f29e3 100644 --- a/cmake/public/glog.cmake +++ b/cmake/public/glog.cmake @@ -68,4 +68,3 @@ if(NOT TARGET glog::glog) "Caffe2 or a Caffe2 dependent library, the next warning / error will " "give you more info.") endif() - diff --git a/cmake/public/utils.cmake b/cmake/public/utils.cmake index f7455f078040..70518520eb01 100644 --- a/cmake/public/utils.cmake +++ b/cmake/public/utils.cmake @@ -484,4 +484,3 @@ function(torch_set_target_props libname) set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG "/NODEFAULTLIB:${VCOMP_LIB}d") endif() endfunction() - diff --git a/docs/caffe2/DOXYGEN.md b/docs/caffe2/DOXYGEN.md index 8adb34d7c892..e25aab818a87 100644 --- a/docs/caffe2/DOXYGEN.md +++ b/docs/caffe2/DOXYGEN.md @@ -71,4 +71,3 @@ def my_method(x, y):"""! ``` Note that the bang (!) is added after the opening comment """! - this seems to do the trick and the remaining comments will be nicely parsed by Doxygen. - diff --git a/docs/cpp/Makefile b/docs/cpp/Makefile index 00a330c754fc..e244432b9fdb 100644 --- a/docs/cpp/Makefile +++ b/docs/cpp/Makefile @@ -25,4 +25,3 @@ clean: # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) - diff --git a/docs/source/community/persons_of_interest.rst b/docs/source/community/persons_of_interest.rst index f346fbe994e6..5c1fcbf1c7ec 100644 --- a/docs/source/community/persons_of_interest.rst +++ b/docs/source/community/persons_of_interest.rst @@ -179,6 +179,3 @@ TorchAudio ~~~~~~~~~~ - Vincent QB (`vincentqb `__) - - - diff --git a/docs/source/dlpack.rst b/docs/source/dlpack.rst index 869285de792d..838c75c0f939 100644 --- a/docs/source/dlpack.rst +++ b/docs/source/dlpack.rst @@ -5,4 +5,3 @@ torch.utils.dlpack .. autofunction:: from_dlpack .. autofunction:: to_dlpack - diff --git a/docs/source/jit_builtin_functions.rst b/docs/source/jit_builtin_functions.rst index 244b87e8f8b5..a6cdb8c47870 100644 --- a/docs/source/jit_builtin_functions.rst +++ b/docs/source/jit_builtin_functions.rst @@ -8,4 +8,3 @@ This is a full reference of functions and Tensor methods accessible in TorchScri .. contents:: :local: .. automodule:: torch.jit.supported_ops - diff --git a/docs/source/notes/cpu_threading_torchscript_inference.svg b/docs/source/notes/cpu_threading_torchscript_inference.svg index 67f8ec884a30..f09884cc5f27 100644 --- a/docs/source/notes/cpu_threading_torchscript_inference.svg +++ b/docs/source/notes/cpu_threading_torchscript_inference.svg @@ -678,4 +678,4 @@ id="g530"> \ No newline at end of file + d="m 375,167.64 h 44.52 V 214.2 H 375 Z" /> diff --git a/docs/source/notes/randomness.rst b/docs/source/notes/randomness.rst index 68b8e74a66aa..304ac3b10ae5 100644 --- a/docs/source/notes/randomness.rst +++ b/docs/source/notes/randomness.rst @@ -149,5 +149,3 @@ Use :meth:`worker_init_fn` to preserve reproducibility:: num_workers=num_workers, worker_init_fn=seed_worker ) - - diff --git a/docs/source/special.rst b/docs/source/special.rst index 20cb8ade1575..0efaf871266f 100644 --- a/docs/source/special.rst +++ b/docs/source/special.rst @@ -24,4 +24,4 @@ Functions .. autofunction:: erfinv .. autofunction:: expm1 .. autofunction:: exp2 -.. autofunction:: gammaln \ No newline at end of file +.. autofunction:: gammaln diff --git a/docs/source/storage.rst b/docs/source/storage.rst index 2a8a04caa0f7..3aeec082b607 100644 --- a/docs/source/storage.rst +++ b/docs/source/storage.rst @@ -85,4 +85,3 @@ Every :class:`torch.Tensor` has a corresponding storage of the same data type. :members: :undoc-members: :inherited-members: - diff --git a/docs/source/torch.nn.intrinsic.quantized.rst b/docs/source/torch.nn.intrinsic.quantized.rst index 042bc868fe33..eebc8c44bb5b 100644 --- a/docs/source/torch.nn.intrinsic.quantized.rst +++ b/docs/source/torch.nn.intrinsic.quantized.rst @@ -19,5 +19,3 @@ LinearReLU ~~~~~~~~~~~~~~~ .. autoclass:: LinearReLU :members: - - diff --git a/docs/source/torch.nn.qat.rst b/docs/source/torch.nn.qat.rst index ae1f60ad59ca..428a05e38cc1 100644 --- a/docs/source/torch.nn.qat.rst +++ b/docs/source/torch.nn.qat.rst @@ -16,6 +16,3 @@ Linear ~~~~~~~~~~~~~~~ .. autoclass:: Linear :members: - - - diff --git a/docs/source/torch.quantization.rst b/docs/source/torch.quantization.rst index 1ae60a7c9de9..bf2461ca22da 100644 --- a/docs/source/torch.quantization.rst +++ b/docs/source/torch.quantization.rst @@ -65,4 +65,3 @@ Debugging utilities :nosignatures: nn.intrinsic - diff --git a/ios/TestApp/.clang-format b/ios/TestApp/.clang-format index 8f647f49fde5..b1a6788085ef 100644 --- a/ios/TestApp/.clang-format +++ b/ios/TestApp/.clang-format @@ -5,4 +5,4 @@ AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false BreakBeforeTernaryOperators: false ColumnLimit: 100 -PointerBindsToType: false \ No newline at end of file +PointerBindsToType: false diff --git a/ios/TestApp/Gemfile b/ios/TestApp/Gemfile index adc90d98cfc4..7a118b49be75 100644 --- a/ios/TestApp/Gemfile +++ b/ios/TestApp/Gemfile @@ -1,3 +1,3 @@ source "https://rubygems.org" -gem "fastlane" \ No newline at end of file +gem "fastlane" diff --git a/ios/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json b/ios/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json index d8db8d65fd79..b542ec24d24e 100644 --- a/ios/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/TestApp/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -95,4 +95,4 @@ "version" : 1, "author" : "xcode" } -} \ No newline at end of file +} diff --git a/ios/TestApp/TestApp/Assets.xcassets/Contents.json b/ios/TestApp/TestApp/Assets.xcassets/Contents.json index da4a164c9186..2d92bd53fdb2 100644 --- a/ios/TestApp/TestApp/Assets.xcassets/Contents.json +++ b/ios/TestApp/TestApp/Assets.xcassets/Contents.json @@ -3,4 +3,4 @@ "version" : 1, "author" : "xcode" } -} \ No newline at end of file +} diff --git a/ios/TestApp/fastlane/Fastfile b/ios/TestApp/fastlane/Fastfile index a69ffa973d40..3e8ef00f0f75 100644 --- a/ios/TestApp/fastlane/Fastfile +++ b/ios/TestApp/fastlane/Fastfile @@ -13,4 +13,4 @@ platform :ios do certificate_password: ENV["IOS_CERT_SECRET"] || "default" ) end -end \ No newline at end of file +end diff --git a/modules/observers/CMakeLists.txt b/modules/observers/CMakeLists.txt index 8796354dc82c..050b8a1461e3 100644 --- a/modules/observers/CMakeLists.txt +++ b/modules/observers/CMakeLists.txt @@ -30,4 +30,3 @@ endif() if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO) set(Caffe2_MODULES ${Caffe2_MODULES} caffe2_observers_library PARENT_SCOPE) endif() - diff --git a/mypy-strict.ini b/mypy-strict.ini index 4608f7cf70f8..5a466e66c433 100644 --- a/mypy-strict.ini +++ b/mypy-strict.ini @@ -46,6 +46,8 @@ files = tools/stats_utils/*.py, tools/test_history.py, tools/test/test_test_history.py, + tools/test/test_trailing_newlines.py, + tools/trailing_newlines.py, torch/testing/_internal/framework_utils.py, torch/utils/benchmark/utils/common.py, torch/utils/benchmark/utils/timer.py, diff --git a/scripts/apache_header.txt b/scripts/apache_header.txt index 67f07905fb0c..b4eff258eb04 100644 --- a/scripts/apache_header.txt +++ b/scripts/apache_header.txt @@ -13,4 +13,3 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - diff --git a/scripts/apache_python.txt b/scripts/apache_python.txt index f946a1a64380..bc104d884515 100644 --- a/scripts/apache_python.txt +++ b/scripts/apache_python.txt @@ -12,4 +12,3 @@ # See the License for the specific language governing permissions and # limitations under the License. ############################################################################## - diff --git a/scripts/diagnose_protobuf.py b/scripts/diagnose_protobuf.py index f8627b60bd12..bc643b397924 100644 --- a/scripts/diagnose_protobuf.py +++ b/scripts/diagnose_protobuf.py @@ -88,7 +88,3 @@ if python_protobuf_installed and native_protobuf_installed: print(VERSION_MISMATCH) else: print('All looks good.') - - - - diff --git a/scripts/release_notes/common.py b/scripts/release_notes/common.py index 4312d71b544c..8f1cfea23c60 100644 --- a/scripts/release_notes/common.py +++ b/scripts/release_notes/common.py @@ -193,4 +193,3 @@ class CommitDataCache: data = {commit: features._asdict() for commit, features in self.data.items()} with open(self.path, 'w') as f: json.dump(data, f) - diff --git a/scripts/xcode_build.rb b/scripts/xcode_build.rb index 1175a8fab887..6fa3394eba93 100644 --- a/scripts/xcode_build.rb +++ b/scripts/xcode_build.rb @@ -80,4 +80,3 @@ end # run xcodebuild exec "xcodebuild clean build -project #{xcodeproj_path} -target #{target.name} -sdk #{sdk} -configuration Release PROVISIONING_PROFILE_SPECIFIER=#{profile} -arch #{arch}" - diff --git a/test/benchmark_utils/callgrind_artifacts.json b/test/benchmark_utils/callgrind_artifacts.json index e59f0524a139..d4cdcdd7804f 100644 --- a/test/benchmark_utils/callgrind_artifacts.json +++ b/test/benchmark_utils/callgrind_artifacts.json @@ -1184,4 +1184,4 @@ "2000 build/../aten/src/TH/THAllocator.cpp:getTHDefaultAllocator() [/data/users/test_user/repos/pytorch/torch/lib/libtorch_cpu.so]", "2000 build/../c10/core/Allocator.h:c10::DefaultCPUAllocator::allocate(unsigned long) const" ] -} \ No newline at end of file +} diff --git a/test/cpp/api/dataloader.cpp b/test/cpp/api/dataloader.cpp index 2d3cb0dfffad..1b7c1291461c 100644 --- a/test/cpp/api/dataloader.cpp +++ b/test/cpp/api/dataloader.cpp @@ -2302,4 +2302,4 @@ TEST(DataLoaderTest, CustomPreprocessPolicy) { } } } -} \ No newline at end of file +} diff --git a/test/cpp/api/init_baseline.h b/test/cpp/api/init_baseline.h index 7565d071474e..1555da67a044 100644 --- a/test/cpp/api/init_baseline.h +++ b/test/cpp/api/init_baseline.h @@ -178,4 +178,4 @@ inline std::vector> Kaiming_Uniform() { }; } -} // namespace expected_parameters \ No newline at end of file +} // namespace expected_parameters diff --git a/test/optim/test.lua b/test/optim/test.lua index 33e47aceba32..3c5fb9f756af 100644 --- a/test/optim/test.lua +++ b/test/optim/test.lua @@ -30,4 +30,3 @@ for i, test in ipairs(tests) do end end end - diff --git a/tools/README.md b/tools/README.md index 76513aa2e421..97d9204afc93 100644 --- a/tools/README.md +++ b/tools/README.md @@ -49,6 +49,10 @@ Developer tools which you might find useful: appropriate subset of our `mypy*.ini` configs. * [test_history.py](test_history.py) - Query S3 to display history of a single test across multiple jobs over time. +* [trailing_newlines.py](trailing_newlines.py) - Take names of UTF-8 files from + stdin, print names of nonempty files whose contents don't end in exactly one + trailing newline, exit with status 1 if no output printed or 0 if some + filenames were printed. Important if you want to run on AMD GPU: diff --git a/tools/autograd/templates/InplaceOrViewType.cpp b/tools/autograd/templates/InplaceOrViewType.cpp index 7ecf84cb3391..e24158bbc9b3 100644 --- a/tools/autograd/templates/InplaceOrViewType.cpp +++ b/tools/autograd/templates/InplaceOrViewType.cpp @@ -30,4 +30,3 @@ TORCH_LIBRARY_IMPL(aten, InplaceOrView, m) { } // namespace } // namespace torch - diff --git a/tools/clang_format_hash/linux64/clang-format-linux64 b/tools/clang_format_hash/linux64/clang-format-linux64 index 40a85640a2aa..784b18bf20a2 100644 --- a/tools/clang_format_hash/linux64/clang-format-linux64 +++ b/tools/clang_format_hash/linux64/clang-format-linux64 @@ -1 +1 @@ -21ca53c291a88b53dac85751b7a0203ca610ac94b7adaff3c092cf30df4168f2 \ No newline at end of file +21ca53c291a88b53dac85751b7a0203ca610ac94b7adaff3c092cf30df4168f2 diff --git a/tools/clang_format_hash/mac/clang-format-mojave b/tools/clang_format_hash/mac/clang-format-mojave index fe4f8f6bdd69..7e4dc1402cb5 100644 --- a/tools/clang_format_hash/mac/clang-format-mojave +++ b/tools/clang_format_hash/mac/clang-format-mojave @@ -1 +1 @@ -5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353 \ No newline at end of file +5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353 diff --git a/tools/test/test_trailing_newlines.py b/tools/test/test_trailing_newlines.py new file mode 100644 index 000000000000..ff6c9e6780c7 --- /dev/null +++ b/tools/test/test_trailing_newlines.py @@ -0,0 +1,49 @@ +from tools import trailing_newlines +import unittest +import tempfile + + +def correct_trailing_newlines(file_contents: str) -> bool: + with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmp: + filename = tmp.name + tmp.write(file_contents) + return trailing_newlines.correct_trailing_newlines(filename) + + +class TestTrailingNewlines(unittest.TestCase): + def test_empty(self) -> None: + self.assertTrue(correct_trailing_newlines('')) + + def test_single_byte(self) -> None: + self.assertFalse(correct_trailing_newlines('a')) + + def test_single_newline(self) -> None: + self.assertFalse(correct_trailing_newlines('\n')) + + def test_two_newlines(self) -> None: + self.assertFalse(correct_trailing_newlines('\n\n')) + + def test_three_newlines(self) -> None: + self.assertFalse(correct_trailing_newlines('\n\n\n')) + + def test_hello_world(self) -> None: + self.assertFalse(correct_trailing_newlines('hello world')) + + def test_hello_world_newline(self) -> None: + self.assertTrue(correct_trailing_newlines('hello world\n')) + + def test_hello_world_two_newlines(self) -> None: + self.assertFalse(correct_trailing_newlines('hello world\n\n')) + + def test_hello_world_three_newlines(self) -> None: + self.assertFalse(correct_trailing_newlines('hello world\n\n\n')) + + def test_hello_world_multiline(self) -> None: + self.assertFalse(correct_trailing_newlines('hello\nworld')) + + def test_hello_world_multiline_gap(self) -> None: + self.assertTrue(correct_trailing_newlines('hello\n\nworld\n')) + + +if __name__ == '__main__': + unittest.main() diff --git a/tools/trailing_newlines.py b/tools/trailing_newlines.py new file mode 100755 index 000000000000..ee743a4785f8 --- /dev/null +++ b/tools/trailing_newlines.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +import fileinput +import os +import sys + +NEWLINE, = b'\n' + + +def correct_trailing_newlines(filename: str) -> bool: + with open(filename, 'rb') as f: + a = len(f.read(2)) + if a == 0: + return True + elif a == 1: + # file is wrong whether or not the only byte is a newline + return False + else: + f.seek(-2, os.SEEK_END) + b, c = f.read(2) + # no ASCII byte is part of any non-ASCII character in UTF-8 + return b != NEWLINE and c == NEWLINE + + +def main() -> int: + # mimic git grep exit code behavior + exit_code = 1 + for line in fileinput.input(): + stripped = line.rstrip() + if not correct_trailing_newlines(stripped): + exit_code = 0 + print(stripped) + return exit_code + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tools/update_disabled_tests.sh b/tools/update_disabled_tests.sh index 1895aee1eced..58f562a13454 100755 --- a/tools/update_disabled_tests.sh +++ b/tools/update_disabled_tests.sh @@ -6,4 +6,4 @@ curl 'https://api.github.com/search/issues?q=is%3Aissue+is%3Aopen+label%3A%22top | sed 's/"score": [0-9\.]*/"score": 0.0/g' > result.json # score changes every request, so we strip it out to avoid creating a commit every time we query. git commit -a -m 'update' -git push \ No newline at end of file +git push diff --git a/torch/_C/_cudnn.pyi b/torch/_C/_cudnn.pyi index 8fa020f5fa6d..e6c7beb31680 100644 --- a/torch/_C/_cudnn.pyi +++ b/torch/_C/_cudnn.pyi @@ -14,4 +14,4 @@ class RNNMode(int, Enum): rnn_relu = ... rnn_tanh = ... lstm = ... - gru = ... \ No newline at end of file + gru = ... diff --git a/torch/_C/_functions.pyi b/torch/_C/_functions.pyi index bbc6606722f3..da2eb27b7cbb 100644 --- a/torch/_C/_functions.pyi +++ b/torch/_C/_functions.pyi @@ -9,4 +9,4 @@ class UndefinedGrad: class DelayedError: def __init__(self, msg: AnyStr, num_inputs: int) -> None: ... def __call__(self, inputs: List[Tensor]) -> List[Tensor]: ... - ... \ No newline at end of file + ... diff --git a/torch/_C/_nn.pyi.in b/torch/_C/_nn.pyi.in index f465b16cfbee..518fbac0a680 100644 --- a/torch/_C/_nn.pyi.in +++ b/torch/_C/_nn.pyi.in @@ -22,4 +22,4 @@ def _parse_to(dtype: _dtype, non_blocking: _bool, copy: _bool, *, memory_format: memory_format) -> Tuple[_device, _dtype, _bool, memory_format]: ... @overload def _parse_to(tensor: Tensor, non_blocking: _bool, copy: _bool, *, - memory_format: memory_format) -> Tuple[_device, _dtype, _bool, memory_format]: ... \ No newline at end of file + memory_format: memory_format) -> Tuple[_device, _dtype, _bool, memory_format]: ... diff --git a/torch/csrc/deploy/CMakeLists.txt b/torch/csrc/deploy/CMakeLists.txt index 44aa11128c6e..9f84cfa0b868 100644 --- a/torch/csrc/deploy/CMakeLists.txt +++ b/torch/csrc/deploy/CMakeLists.txt @@ -25,4 +25,3 @@ target_link_libraries(test_deploy PUBLIC gtest dl torch_deploy) add_executable(deploy_benchmark ${DEPLOY_DIR}/example/benchmark.cpp) target_include_directories(deploy_benchmark PRIVATE ${PYTORCH_ROOT}/torch) target_link_libraries(deploy_benchmark PUBLIC torch_deploy) - diff --git a/torch/csrc/jit/serialization/source_range_serialization_impl.h b/torch/csrc/jit/serialization/source_range_serialization_impl.h index 17bf91551ed2..7f6e4181394b 100644 --- a/torch/csrc/jit/serialization/source_range_serialization_impl.h +++ b/torch/csrc/jit/serialization/source_range_serialization_impl.h @@ -26,4 +26,4 @@ class ConcreteSourceRangeUnpickler : public SourceRangeUnpickler { }; } // namespace jit -} // namespace torch \ No newline at end of file +} // namespace torch diff --git a/torch/csrc/python_dimname.cpp b/torch/csrc/python_dimname.cpp index 64407a6ee8d4..09dbd7194b71 100644 --- a/torch/csrc/python_dimname.cpp +++ b/torch/csrc/python_dimname.cpp @@ -97,4 +97,3 @@ at::Dimname THPDimname_parse(PyObject* obj) { torch::kPyInternedStringToDimname.addMapping(obj, dimname); return dimname; } - diff --git a/torch/csrc/python_dimname.h b/torch/csrc/python_dimname.h index 387eabf687aa..2bca0f07344f 100644 --- a/torch/csrc/python_dimname.h +++ b/torch/csrc/python_dimname.h @@ -5,4 +5,3 @@ at::Dimname THPDimname_parse(PyObject* obj); bool THPUtils_checkDimname(PyObject* obj); bool THPUtils_checkDimnameList(PyObject* obj); - diff --git a/torch/csrc/python_headers.h b/torch/csrc/python_headers.h index 2a64bdd5c6ee..f255f56e9e08 100644 --- a/torch/csrc/python_headers.h +++ b/torch/csrc/python_headers.h @@ -16,4 +16,3 @@ #if PY_MAJOR_VERSION < 3 #error "Python 2 has reached end-of-life and is no longer supported by PyTorch." #endif - diff --git a/torch/deploy.h b/torch/deploy.h index 8fa95d7c7cad..87338adaba1d 100644 --- a/torch/deploy.h +++ b/torch/deploy.h @@ -1,3 +1,3 @@ #pragma once -#include \ No newline at end of file +#include diff --git a/torch/optim/_multi_tensor/__init__.pyi b/torch/optim/_multi_tensor/__init__.pyi index 952b969012b7..1d1ec63c777e 100644 --- a/torch/optim/_multi_tensor/__init__.pyi +++ b/torch/optim/_multi_tensor/__init__.pyi @@ -5,4 +5,4 @@ from .rmsprop import RMSprop as RMSprop from .rprop import Rprop as Rprop from .asgd import ASGD as ASGD from .adamax import Adamax as Adamax -from .adadelta import Adadelta as Adadelta \ No newline at end of file +from .adadelta import Adadelta as Adadelta diff --git a/torch/optim/_multi_tensor/adadelta.pyi b/torch/optim/_multi_tensor/adadelta.pyi index 0ca4478a16da..37f933020246 100644 --- a/torch/optim/_multi_tensor/adadelta.pyi +++ b/torch/optim/_multi_tensor/adadelta.pyi @@ -2,4 +2,4 @@ from typing import Tuple from ..optimizer import _params_t, Optimizer class Adadelta(Optimizer): - def __init__(self, params: _params_t, lr: float=..., rho: float=..., eps: float=..., weight_decay: float=...) -> None: ... \ No newline at end of file + def __init__(self, params: _params_t, lr: float=..., rho: float=..., eps: float=..., weight_decay: float=...) -> None: ...