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
This commit is contained in:
Sam Estep
2021-03-30 13:05:16 -07:00
committed by Facebook GitHub Bot
parent eafa235582
commit 5bcbbf5373
111 changed files with 122 additions and 132 deletions

View File

@ -1129,4 +1129,3 @@ JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved);
#define JNI_ABORT 2 /* free buffer w/o copying back */ #define JNI_ABORT 2 /* free buffer w/o copying back */
#endif /* JNI_H_ */ #endif /* JNI_H_ */

View File

@ -30,6 +30,9 @@ jobs:
rm -r "shellcheck-${scversion}" rm -r "shellcheck-${scversion}"
shellcheck --version shellcheck --version
.jenkins/run-shellcheck.sh .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 - name: Ensure no trailing spaces
run: | run: |
(! git grep -I -no ' $' -- . ':(exclude)**/contrib/**' ':(exclude)third_party' || (echo "The above files have trailing spaces; please remove them"; false)) (! git grep -I -no ' $' -- . ':(exclude)**/contrib/**' ':(exclude)third_party' || (echo "The above files have trailing spaces; please remove them"; false))

View File

@ -27,4 +27,3 @@ test_cpu_speed_torch () {
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
run_test test_cpu_speed_torch "$@" run_test test_cpu_speed_torch "$@"
fi fi

View File

@ -27,4 +27,3 @@ test_cpu_speed_torch_tensor () {
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
run_test test_cpu_speed_torch_tensor "$@" run_test test_cpu_speed_torch_tensor "$@"
fi fi

View File

@ -14,4 +14,4 @@
android:background="@android:color/black" android:background="@android:color/black"
android:textColor="@android:color/white" /> android:textColor="@android:color/white" />
</FrameLayout> </FrameLayout>

View File

@ -105,4 +105,3 @@ C10_HOST_DEVICE inline double tan<double>(double x) {
} }
} // namespace at } // namespace at

View File

@ -594,4 +594,3 @@ Vec256<ComplexDbl> inline minimum(
} // namespace } // namespace
} // namespace vec256 } // namespace vec256
} // namespace at } // namespace at

View File

@ -386,4 +386,3 @@ const vfloat64 vd_pi_2 = vfloat64{M_PI / 2.0, 0.0};
} // namespace } // namespace
} // namespace vec256 } // namespace vec256
} // namespace at } // namespace at

View File

@ -13,4 +13,3 @@
#undef STRINGIFY #undef STRINGIFY
#undef STRING #undef STRING

View File

@ -8,4 +8,3 @@ static inline T div_rtn(T x, T y) {
if ((r!=0) && ((r<0) != (y<0))) --q; if ((r!=0) && ((r<0) != (y<0))) --q;
return q; return q;
} }

View File

@ -10,4 +10,3 @@ using cross_fn = void(*)(Tensor&, const Tensor&, const Tensor&, const int64_t d)
DECLARE_DISPATCH(cross_fn, cross_stub); DECLARE_DISPATCH(cross_fn, cross_stub);
}} // namespace at::native }} // namespace at::native

View File

@ -15,4 +15,3 @@ DECLARE_DISPATCH(batch_norm_fn, batch_norm_cpu_inference_contiguous_stub);
} // namespace native } // namespace native
} // namespace at } // namespace at

View File

@ -75,4 +75,3 @@ static void cross_kernel_impl(Tensor& result, const Tensor& a, const Tensor& b,
REGISTER_DISPATCH(cross_stub, &cross_kernel_impl); REGISTER_DISPATCH(cross_stub, &cross_kernel_impl);
}} // namespace at::native }} // namespace at::native

View File

@ -12,4 +12,3 @@ void cross_kernel_impl(Tensor& result, const Tensor& x1, const Tensor& x2, const
REGISTER_DISPATCH(cross_stub, &cross_kernel_impl); REGISTER_DISPATCH(cross_stub, &cross_kernel_impl);
}} }}

View File

@ -33,4 +33,4 @@ Tensor embedding_backward_cuda_kernel(
const Tensor &bag_size = Tensor(), const Tensor &bag_size = Tensor(),
const Tensor &per_sample_weights = Tensor()); const Tensor &per_sample_weights = Tensor());
}} }}

View File

@ -13,4 +13,4 @@
IS THE CASE CAN LEAD TO HARD-TO-DEBUG ODR VIOLATIONS. IS THE CASE CAN LEAD TO HARD-TO-DEBUG ODR VIOLATIONS.
- **Make sure different variants of the code (AVX, AVX2) are tested!** - **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 There are build variants that do things like have NO AVX and NO AVX2 in
CI. Make sure they work! CI. Make sure they work!

View File

@ -31,4 +31,4 @@ outlined on that page and do not file a public issue.
## License ## License
By contributing to QNNPACK, you agree that your contributions will be licensed By contributing to QNNPACK, you agree that your contributions will be licensed
under the LICENSE file in the root directory of this source tree. under the LICENSE file in the root directory of this source tree.

View File

@ -233,5 +233,3 @@ TEST(NamedTensorTest, TensorNamesCheckUnique) {
ASSERT_THROW(tensornames.checkUnique("op_name"), c10::Error); ASSERT_THROW(tensornames.checkUnique("op_name"), c10::Error);
} }
} }

View File

@ -35,4 +35,3 @@ __global__ void CUDA##a##b()
#define C10_DEFINE_TEST(a, b) TEST(a##Host, b) #define C10_DEFINE_TEST(a, b) TEST(a##Host, b)
#define C10_ASSERT_NEAR(a, b, tol) ASSERT_NEAR(a, b, tol) #define C10_ASSERT_NEAR(a, b, tol) ASSERT_NEAR(a, b, tol)
#include <c10/test/util/complex_math_test_common.h> #include <c10/test/util/complex_math_test_common.h>

View File

@ -364,4 +364,3 @@ TEST(PowTest, TestIntegralPow) {
test_inverse(longs); test_inverse(longs);
test_inverse(ints); test_inverse(ints);
} }

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -1,3 +1,2 @@
#include <THC/THCTensorMathCompareT.cuh> #include <THC/THCTensorMathCompareT.cuh>
#include <THC/THCTensor.hpp> #include <THC/THCTensor.hpp>

View File

@ -26,4 +26,3 @@ python -c "import torch; print(torch.__version__)"
Please refer to each subfolder to discover each benchmark suite Please refer to each subfolder to discover each benchmark suite
* [Fast RNNs benchmarks](fastrnns/README.md) * [Fast RNNs benchmarks](fastrnns/README.md)

View File

@ -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 Use Linux for the most accurate timing. A lot of these tests only run
on CUDA. on CUDA.

View File

@ -7,4 +7,4 @@
#if (!defined(__CUDA_ARCH__) || !defined(CUDA_VERSION) || CUDA_VERSION > 9200) #if (!defined(__CUDA_ARCH__) || !defined(CUDA_VERSION) || CUDA_VERSION > 9200)
static_assert(C10_IS_TRIVIALLY_COPYABLE(c10::optional<int>), "c10::optional<int> should be trivially copyable"); static_assert(C10_IS_TRIVIALLY_COPYABLE(c10::optional<int>), "c10::optional<int> should be trivially copyable");
static_assert(C10_IS_TRIVIALLY_COPYABLE(c10::optional<bool>), "c10::optional<bool> should be trivially copyable"); static_assert(C10_IS_TRIVIALLY_COPYABLE(c10::optional<bool>), "c10::optional<bool> should be trivially copyable");
#endif #endif

View File

@ -46,4 +46,4 @@ std::string u16u8(const std::wstring& wstr) {
return str; return str;
} }
#endif #endif
} // namespace c10 } // namespace c10

View File

@ -41,5 +41,3 @@ TEST(CommonTest, TestStod) {
#endif // __ANDROID__ #endif // __ANDROID__
} // namespace caffe2 } // namespace caffe2

View File

@ -123,4 +123,3 @@ TEST(Subgraph, InduceEdgesCycle) {
EXPECT_TRUE(sg.hasEdge(edge)); EXPECT_TRUE(sg.hasEdge(edge));
} }
} }

View File

@ -15,4 +15,3 @@ Device::Device(const std::string &spec) {
device_id = atoi(spec.substr(pos + 1).c_str()); device_id = atoi(spec.substr(pos + 1).c_str());
} }
}} }}

View File

@ -312,4 +312,3 @@ C10_EXPORT_CAFFE2_OP_TO_C10_CPU(
" bool aligned" " bool aligned"
") -> Tensor", ") -> Tensor",
caffe2::RoIAlignCPUOp<float>); caffe2::RoIAlignCPUOp<float>);

View File

@ -45,4 +45,3 @@ NetDef optimize(NetDef net, int level) {
} // namespace opt } // namespace opt
} // namespace caffe2 } // namespace caffe2

View File

@ -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_CPU_PYTHON_SRCS ${Caffe2_CPU_PYTHON_SRCS} PARENT_SCOPE)
set(Caffe2_GPU_PYTHON_SRCS ${Caffe2_GPU_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) set(Caffe2_HIP_PYTHON_SRCS ${Caffe2_HIP_PYTHON_SRCS} PARENT_SCOPE)

View File

@ -1,7 +1,2 @@
## @package workspace ## @package workspace
# Module caffe2.python.workspace # Module caffe2.python.workspace

View File

@ -7,4 +7,3 @@ if 'OSS_ONNXIFI_LIB' in os.environ:
lib = os.environ['OSS_ONNXIFI_LIB'] lib = os.environ['OSS_ONNXIFI_LIB']
print("Loading ONNXIFI lib: ".format(lib)) print("Loading ONNXIFI lib: ".format(lib))
ctypes.CDLL(lib, ctypes.RTLD_GLOBAL) ctypes.CDLL(lib, ctypes.RTLD_GLOBAL)

View File

@ -51,4 +51,3 @@ pip install -e caffe2/
# License # License
[MIT License](LICENSE) [MIT License](LICENSE)

View File

@ -49,4 +49,3 @@ class Caffe2CppRep(BackendRep):
# single input # single input
output_values = self.__core.run([inputs]) output_values = self.__core.run([inputs])
return namedtupledict('Outputs', self.__external_outputs)(*output_values) return namedtupledict('Outputs', self.__external_outputs)(*output_values)

View File

@ -197,5 +197,3 @@ class OnnxifiTransformTest(TestCase):
output_values = [workspace.FetchBlob(name) for name in net_outputs] output_values = [workspace.FetchBlob(name) for name in net_outputs]
Y_trt = namedtupledict('Outputs', net_outputs)(*output_values) Y_trt = namedtupledict('Outputs', net_outputs)(*output_values)
np.testing.assert_allclose(Y_c2, Y_trt, rtol=1e-3) np.testing.assert_allclose(Y_c2, Y_trt, rtol=1e-3)

View File

@ -1,4 +0,0 @@

View File

@ -27,4 +27,3 @@ class TestCase(unittest.TestCase):
if hasattr(self, name): if hasattr(self, name):
raise ValueError('Duplicated test name: {}'.format(name)) raise ValueError('Duplicated test name: {}'.format(name))
setattr(self, name, test_func) setattr(self, name, test_func)

View File

@ -60,4 +60,3 @@ class TestMean(serial.SerializedTestCase):
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View File

@ -1,5 +0,0 @@

View File

@ -876,4 +876,3 @@ Serialized tests have covered 220/852 (25.8%) operators
* LengthsSumFakeFp16 * LengthsSumFakeFp16
* SparseLengthsMax * SparseLengthsMax
</details> </details>

View File

@ -997,4 +997,4 @@ earthstar
hen-of-the-woods hen-of-the-woods
bolete bolete
ear ear
toilet tissue toilet tissue

View File

@ -277,5 +277,3 @@ class TensorRTTransformTest(TestCase):
output_values = [workspace.FetchBlob(name) for name in net_outputs] output_values = [workspace.FetchBlob(name) for name in net_outputs]
Y_trt = namedtupledict('Outputs', net_outputs)(*output_values) Y_trt = namedtupledict('Outputs', net_outputs)(*output_values)
np.testing.assert_allclose(Y_c2, Y_trt, rtol=1e-3) np.testing.assert_allclose(Y_c2, Y_trt, rtol=1e-3)

View File

@ -106,4 +106,3 @@ def transform_caffe2_net(
pred_net_cut = caffe2_pb2.NetDef() pred_net_cut = caffe2_pb2.NetDef()
pred_net_cut.ParseFromString(pred_net_str) pred_net_cut.ParseFromString(pred_net_str)
return pred_net_cut return pred_net_cut

View File

@ -68,5 +68,3 @@ TEST(SimpleQueueDeathTest, CannotAddAfterQueueFinished) {
} // namespace caffe2 } // namespace caffe2

View File

@ -49,4 +49,3 @@ if(ATLAS_FOUND)
message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})") message(STATUS "Found Atlas (include: ${Atlas_CBLAS_INCLUDE_DIR}, library: ${Atlas_BLAS_LIBRARY})")
endif(ATLAS_FOUND) endif(ATLAS_FOUND)

View File

@ -21,4 +21,3 @@ if(HIREDIS_FOUND)
message(STATUS "Found Hiredis (include: ${Hiredis_INCLUDE_DIR}, library: ${Hiredis_LIBRARIES})") message(STATUS "Found Hiredis (include: ${Hiredis_INCLUDE_DIR}, library: ${Hiredis_LIBRARIES})")
mark_as_advanced(Hiredis_INCLUDE_DIR Hiredis_LIBRARIES) mark_as_advanced(Hiredis_INCLUDE_DIR Hiredis_LIBRARIES)
endif() endif()

View File

@ -55,4 +55,3 @@ if(NUMPY_FOUND)
endif() endif()
caffe_clear_vars(__result __output __error_value __values __ver_check __error_value) caffe_clear_vars(__result __output __error_value __values __ver_check __error_value)

View File

@ -26,4 +26,3 @@ if(NUMA_FOUND)
"Found Numa (include: ${Numa_INCLUDE_DIR}, library: ${Numa_LIBRARIES})") "Found Numa (include: ${Numa_INCLUDE_DIR}, library: ${Numa_LIBRARIES})")
mark_as_advanced(Numa_INCLUDE_DIR Numa_LIBRARIES) mark_as_advanced(Numa_INCLUDE_DIR Numa_LIBRARIES)
endif() endif()

View File

@ -63,4 +63,3 @@ MARK_AS_ADVANCED(
OpenBLAS_LIB OpenBLAS_LIB
OpenBLAS OpenBLAS
) )

View File

@ -21,4 +21,3 @@ if(ROCKSDB_FOUND)
message(STATUS "Found RocksDB (include: ${RocksDB_INCLUDE_DIR}, library: ${RocksDB_LIBRARIES})") message(STATUS "Found RocksDB (include: ${RocksDB_INCLUDE_DIR}, library: ${RocksDB_LIBRARIES})")
mark_as_advanced(RocksDB_INCLUDE_DIR RocksDB_LIBRARIES) mark_as_advanced(RocksDB_INCLUDE_DIR RocksDB_LIBRARIES)
endif() endif()

View File

@ -24,4 +24,3 @@ if(SNAPPY_FOUND)
SNAPPY_VERION_LINES SNAPPY_MAJOR SNAPPY_MINOR SNAPPY_PATCHLEVEL) SNAPPY_VERION_LINES SNAPPY_MAJOR SNAPPY_MINOR SNAPPY_PATCHLEVEL)
set(Snappy_VERSION "${SNAPPY_MAJOR}.${SNAPPY_MINOR}.${SNAPPY_PATCHLEVEL}") set(Snappy_VERSION "${SNAPPY_MAJOR}.${SNAPPY_MINOR}.${SNAPPY_PATCHLEVEL}")
endif() endif()

View File

@ -32,4 +32,3 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
endif() endif()
message("-- </FindVSX>") message("-- </FindVSX>")
endif() endif()

View File

@ -107,5 +107,3 @@ if (NOT "${file_text}" STREQUAL "")
else() else()
# message("FOUND NO DEPENDS") # message("FOUND NO DEPENDS")
endif() endif()

View File

@ -81,4 +81,3 @@ if(NOT TARGET gflags)
"Caffe2 or a Caffe2 dependent library, the next warning / error will " "Caffe2 or a Caffe2 dependent library, the next warning / error will "
"give you more info.") "give you more info.")
endif() endif()

View File

@ -68,4 +68,3 @@ if(NOT TARGET glog::glog)
"Caffe2 or a Caffe2 dependent library, the next warning / error will " "Caffe2 or a Caffe2 dependent library, the next warning / error will "
"give you more info.") "give you more info.")
endif() endif()

View File

@ -484,4 +484,3 @@ function(torch_set_target_props libname)
set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG "/NODEFAULTLIB:${VCOMP_LIB}d") set_target_properties(${libname} PROPERTIES STATIC_LIBRARY_FLAGS_DEBUG "/NODEFAULTLIB:${VCOMP_LIB}d")
endif() endif()
endfunction() endfunction()

View File

@ -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. 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.

View File

@ -25,4 +25,3 @@ clean:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile %: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

View File

@ -179,6 +179,3 @@ TorchAudio
~~~~~~~~~~ ~~~~~~~~~~
- Vincent QB (`vincentqb <https://github.com/vincentqb>`__) - Vincent QB (`vincentqb <https://github.com/vincentqb>`__)

View File

@ -5,4 +5,3 @@ torch.utils.dlpack
.. autofunction:: from_dlpack .. autofunction:: from_dlpack
.. autofunction:: to_dlpack .. autofunction:: to_dlpack

View File

@ -8,4 +8,3 @@ This is a full reference of functions and Tensor methods accessible in TorchScri
.. contents:: :local: .. contents:: :local:
.. automodule:: torch.jit.supported_ops .. automodule:: torch.jit.supported_ops

View File

@ -678,4 +678,4 @@
id="g530"><path id="g530"><path
id="path532" id="path532"
style="fill:none;stroke:#000000;stroke-width:0.47999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:1.92, 1.44;stroke-dashoffset:0;stroke-opacity:1" style="fill:none;stroke:#000000;stroke-width:0.47999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:10;stroke-dasharray:1.92, 1.44;stroke-dashoffset:0;stroke-opacity:1"
d="m 375,167.64 h 44.52 V 214.2 H 375 Z" /></g></g></svg> d="m 375,167.64 h 44.52 V 214.2 H 375 Z" /></g></g></svg>

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -149,5 +149,3 @@ Use :meth:`worker_init_fn` to preserve reproducibility::
num_workers=num_workers, num_workers=num_workers,
worker_init_fn=seed_worker worker_init_fn=seed_worker
) )

View File

@ -24,4 +24,4 @@ Functions
.. autofunction:: erfinv .. autofunction:: erfinv
.. autofunction:: expm1 .. autofunction:: expm1
.. autofunction:: exp2 .. autofunction:: exp2
.. autofunction:: gammaln .. autofunction:: gammaln

View File

@ -85,4 +85,3 @@ Every :class:`torch.Tensor` has a corresponding storage of the same data type.
:members: :members:
:undoc-members: :undoc-members:
:inherited-members: :inherited-members:

View File

@ -19,5 +19,3 @@ LinearReLU
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
.. autoclass:: LinearReLU .. autoclass:: LinearReLU
:members: :members:

View File

@ -16,6 +16,3 @@ Linear
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
.. autoclass:: Linear .. autoclass:: Linear
:members: :members:

View File

@ -65,4 +65,3 @@ Debugging utilities
:nosignatures: :nosignatures:
nn.intrinsic nn.intrinsic

View File

@ -5,4 +5,4 @@ AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false AllowShortLoopsOnASingleLine: false
BreakBeforeTernaryOperators: false BreakBeforeTernaryOperators: false
ColumnLimit: 100 ColumnLimit: 100
PointerBindsToType: false PointerBindsToType: false

View File

@ -1,3 +1,3 @@
source "https://rubygems.org" source "https://rubygems.org"
gem "fastlane" gem "fastlane"

View File

@ -95,4 +95,4 @@
"version" : 1, "version" : 1,
"author" : "xcode" "author" : "xcode"
} }
} }

View File

@ -3,4 +3,4 @@
"version" : 1, "version" : 1,
"author" : "xcode" "author" : "xcode"
} }
} }

View File

@ -13,4 +13,4 @@ platform :ios do
certificate_password: ENV["IOS_CERT_SECRET"] || "default" certificate_password: ENV["IOS_CERT_SECRET"] || "default"
) )
end end
end end

View File

@ -30,4 +30,3 @@ endif()
if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO) if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
set(Caffe2_MODULES ${Caffe2_MODULES} caffe2_observers_library PARENT_SCOPE) set(Caffe2_MODULES ${Caffe2_MODULES} caffe2_observers_library PARENT_SCOPE)
endif() endif()

View File

@ -46,6 +46,8 @@ files =
tools/stats_utils/*.py, tools/stats_utils/*.py,
tools/test_history.py, tools/test_history.py,
tools/test/test_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/testing/_internal/framework_utils.py,
torch/utils/benchmark/utils/common.py, torch/utils/benchmark/utils/common.py,
torch/utils/benchmark/utils/timer.py, torch/utils/benchmark/utils/timer.py,

View File

@ -13,4 +13,3 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */

View File

@ -12,4 +12,3 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
############################################################################## ##############################################################################

View File

@ -88,7 +88,3 @@ if python_protobuf_installed and native_protobuf_installed:
print(VERSION_MISMATCH) print(VERSION_MISMATCH)
else: else:
print('All looks good.') print('All looks good.')

View File

@ -193,4 +193,3 @@ class CommitDataCache:
data = {commit: features._asdict() for commit, features in self.data.items()} data = {commit: features._asdict() for commit, features in self.data.items()}
with open(self.path, 'w') as f: with open(self.path, 'w') as f:
json.dump(data, f) json.dump(data, f)

View File

@ -80,4 +80,3 @@ end
# run xcodebuild # run xcodebuild
exec "xcodebuild clean build -project #{xcodeproj_path} -target #{target.name} -sdk #{sdk} -configuration Release PROVISIONING_PROFILE_SPECIFIER=#{profile} -arch #{arch}" exec "xcodebuild clean build -project #{xcodeproj_path} -target #{target.name} -sdk #{sdk} -configuration Release PROVISIONING_PROFILE_SPECIFIER=#{profile} -arch #{arch}"

View File

@ -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/../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" "2000 build/../c10/core/Allocator.h:c10::DefaultCPUAllocator::allocate(unsigned long) const"
] ]
} }

View File

@ -2302,4 +2302,4 @@ TEST(DataLoaderTest, CustomPreprocessPolicy) {
} }
} }
} }
} }

View File

@ -178,4 +178,4 @@ inline std::vector<std::vector<torch::Tensor>> Kaiming_Uniform() {
}; };
} }
} // namespace expected_parameters } // namespace expected_parameters

View File

@ -30,4 +30,3 @@ for i, test in ipairs(tests) do
end end
end end
end end

View File

@ -49,6 +49,10 @@ Developer tools which you might find useful:
appropriate subset of our `mypy*.ini` configs. appropriate subset of our `mypy*.ini` configs.
* [test_history.py](test_history.py) - Query S3 to display history of a single * [test_history.py](test_history.py) - Query S3 to display history of a single
test across multiple jobs over time. 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: Important if you want to run on AMD GPU:

View File

@ -30,4 +30,3 @@ TORCH_LIBRARY_IMPL(aten, InplaceOrView, m) {
} // namespace } // namespace
} // namespace torch } // namespace torch

View File

@ -1 +1 @@
21ca53c291a88b53dac85751b7a0203ca610ac94b7adaff3c092cf30df4168f2 21ca53c291a88b53dac85751b7a0203ca610ac94b7adaff3c092cf30df4168f2

View File

@ -1 +1 @@
5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353 5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353

View File

@ -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()

37
tools/trailing_newlines.py Executable file
View File

@ -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())

View File

@ -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 | 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. # score changes every request, so we strip it out to avoid creating a commit every time we query.
git commit -a -m 'update' git commit -a -m 'update'
git push git push

Some files were not shown because too many files have changed in this diff Show More