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 f793148c1df0f..1fdc6f3ad69d3 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 d1c9d91148e9b..dd1197b4adba3 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 e805389aeaa87..b8f9801341427 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 6dc5a7b200b43..c0226206075cc 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 c0939ebc0ebca..556839a994c58 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 e6726602bbd57..ecac8cfe3dcec 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 8613358611232..d4f76197c6e4e 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 61a572e1abcc1..a9ccf5543baec 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 66a926fe577f1..0358b15c117f7 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 7b6beec4b063b..f9cafb8ed1a7f 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 35f9886b2b086..5517f601e6af5 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 9ff05b70ccd4a..bd78a5b7ebe24 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 0d405447bc1a9..55e02295a9f88 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 d03ee0009cd68..31fd2a90887d6 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 e483550dc1ed8..960b28afb8c74 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 dc3f6cfe14d1d..c3685ac9d6997 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 cd6b1221a0717..9a17a037b6942 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 0872d9265946e..d1468ac0680b0 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 fe444a78e7bc5..ddc60dfd2ab2d 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 c865f050dc48e..948841ae36ad8 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 17e2a4f72a351..9624e950fe134 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 56b3159e5ea0c..3665818ab2d43 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 830190e283325..7cd51d4356c70 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 dd91391719b45..ce2ee24e35dd7 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 e6d41bc731867..1c7eefc57b5af 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 4e9b65828a81d..7de0a73709902 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 e0de91bb2ade3..65f8ad5f88c92 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 7808c54f307a9..9dd2d1c76c37c 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 02120137465f1..2367e525b93d6 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 2e707a13828f2..72de6d861598f 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 ee910e831e8b0..373a4fff86b64 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 b4b37811de107..b3b5822c46ca2 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 2a98de4571aa7..889b2bcab5205 100644 --- a/caffe2/python/fakelowp/init_shared_libs.py +++ b/caffe2/python/fakelowp/init_shared_libs.py @@ -7,4 +7,3 @@ 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 441914fb16b2d..444951bf684aa 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 4a75068cfd03a..322e6c2e28945 100644 --- a/caffe2/python/onnx/backend_cpp_rep.py +++ b/caffe2/python/onnx/backend_cpp_rep.py @@ -49,4 +49,3 @@ def run(self, inputs): # 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 4316149d5bf67..73a120616985e 100644 --- a/caffe2/python/onnx/test_onnxifi.py +++ b/caffe2/python/onnx/test_onnxifi.py @@ -197,5 +197,3 @@ def test_resnet50_core(self): 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 fd40910d9e70d..e69de29bb2d1d 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 bebfc1012957d..8585624e1af80 100644 --- a/caffe2/python/onnx/tests/test_utils.py +++ b/caffe2/python/onnx/tests/test_utils.py @@ -27,4 +27,3 @@ def add_test_case(self, name, test_func): 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 ee2c6fc8fbf7a..a549426170ce6 100644 --- a/caffe2/python/operator_test/mean_op_test.py +++ b/caffe2/python/operator_test/mean_op_test.py @@ -60,4 +60,3 @@ def mean_ref(*args): if __name__ == "__main__": unittest.main() - diff --git a/caffe2/python/rnn/__init__.py b/caffe2/python/rnn/__init__.py index 3f2ff2d6cc8f2..e69de29bb2d1d 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 f98dad595b889..4e61b65ec44d3 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 888d6f51dd77b..f40829ed0fc31 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 2782cca7c13ff..6f9426d6a93aa 100644 --- a/caffe2/python/trt/test_trt.py +++ b/caffe2/python/trt/test_trt.py @@ -277,5 +277,3 @@ def test_resnet50_core(self): 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 1b201007daab8..0e304ca4fae30 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 d0cf24acbf251..f9d2fa801b60f 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 9c665a47bd580..efacda1e26ad0 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 b9cb69b69a8db..f1389ded5868c 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 a671494cababa..b1b93c772bba0 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 63fbe9014c160..b27b646e8a9a5 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 be9e713d16f56..c909ace0a1763 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 e33bcce2f85fa..ef7f3b5f94b3d 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 77fd32b85a710..97219e85075a8 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 64f67ceeb0e3c..304b3c90b5b40 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 626c8a2e47d3c..25ceb49f3dd8e 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 a030fdd7d4299..186cda1a909ab 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 a067c8dc78750..bb03e81f29e3a 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 f7455f078040c..70518520eb01b 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 8adb34d7c892c..e25aab818a876 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 00a330c754fc2..e244432b9fdb3 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 f346fbe994e6c..5c1fcbf1c7ecb 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 869285de792d1..838c75c0f9399 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 244b87e8f8b53..a6cdb8c478704 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 67f8ec884a309..f09884cc5f274 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 68b8e74a66aa6..304ac3b10ae5d 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 20cb8ade15758..0efaf871266fc 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 2a8a04caa0f7e..3aeec082b607b 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 042bc868fe338..eebc8c44bb5b8 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 ae1f60ad59ca9..428a05e38cc17 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 1ae60a7c9de95..bf2461ca22daf 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 8f647f49fde58..b1a6788085ef6 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 adc90d98cfc4a..7a118b49be750 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 d8db8d65fd79f..b542ec24d24ea 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 da4a164c91865..2d92bd53fdb22 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 a69ffa973d402..3e8ef00f0f759 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 8796354dc82c6..050b8a1461e32 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 4608f7cf70f86..5a466e66c4334 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 67f07905fb0cb..b4eff258eb04d 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 f946a1a64380a..bc104d8845154 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 f8627b60bd123..bc643b3979248 100644 --- a/scripts/diagnose_protobuf.py +++ b/scripts/diagnose_protobuf.py @@ -88,7 +88,3 @@ print(VERSION_MISMATCH) else: print('All looks good.') - - - - diff --git a/scripts/release_notes/common.py b/scripts/release_notes/common.py index 4312d71b544cc..8f1cfea23c60c 100644 --- a/scripts/release_notes/common.py +++ b/scripts/release_notes/common.py @@ -193,4 +193,3 @@ def write_to_disk(self): 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 1175a8fab8871..6fa3394eba932 100644 --- a/scripts/xcode_build.rb +++ b/scripts/xcode_build.rb @@ -80,4 +80,3 @@ # 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 e59f0524a139f..d4cdcdd7804fa 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 2d3cb0dfffad9..1b7c1291461cd 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 7565d071474ed..1555da67a0442 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 33e47aceba32b..3c5fb9f756afe 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 76513aa2e4211..97d9204afc938 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 7ecf84cb3391e..e24158bbc9b3d 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 40a85640a2aa3..784b18bf20a29 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 fe4f8f6bdd69e..7e4dc1402cb5f 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 0000000000000..ff6c9e6780c75 --- /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 0000000000000..ee743a4785f88 --- /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 1895aee1eced4..58f562a134542 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 8fa020f5fa6df..e6c7beb31680f 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 bbc6606722f3f..da2eb27b7cbb1 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 f465b16cfbeec..518fbac0a6803 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 44aa11128c6e3..9f84cfa0b8687 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 17bf91551ed20..7f6e4181394b1 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 64407a6ee8d40..09dbd7194b718 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 387eabf687aae..2bca0f07344f2 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 2a64bdd5c6ee0..f255f56e9e084 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 8fa95d7c7cadf..87338adaba1df 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 952b969012b79..1d1ec63c777eb 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 0ca4478a16da6..37f933020246b 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: ...