pytorch
7c2641d5 - apply constexpr and if constexpr when possible (#102471)

Commit
1 year ago
apply constexpr and if constexpr when possible (#102471) Now that we have full C++17 support, we can use if constexpr in some identified cases. <!-- copilot:summary --> ### <samp>🤖 Generated by Copilot at df4c16d</samp> The pull request improves the performance, readability, and consistency of various function templates in the `ATen` and `torch` modules by using `constexpr` keywords and C++17 features. It also fixes some type conversion and overflow issues for different input and output types. The changes affect the code for distributions, BLAS, batch normalization, embedding bag, random number generation, vectorized operations, cuBLAS, XNNPACK, CUTLASS, and shape inference. The affected files include `DistributionsHelper.h`, `vec256_int.h`, `vec512_int.h`, `BlasKernel.cpp`, `IndexKernel.cpp`, `EmbeddingBag.cpp`, `Normalization.cpp`, `rng_test.h`, `vec_test_all_types.h`, `TransformationHelper.h`, `CUDABlas.cpp`, `DistributionKernels.cpp`, `DistributionTemplates.h`, `RangeFactories.cu`, `RangeFactories.cpp`, `qconv.cpp`, `StructuredSparseLinearCUTLASS.cu`, `vec_test_all_types.cpp`, and `shape_inference.cpp`. Pull Request resolved: https://github.com/pytorch/pytorch/pull/102471 Approved by: https://github.com/Skylion007, https://github.com/malfet
Author
Committer
Parents
Loading