diff --git a/aten/src/ATen/Dispatch.h b/aten/src/ATen/Dispatch.h index 30114e42d3d..5c7b39c6427 100644 --- a/aten/src/ATen/Dispatch.h +++ b/aten/src/ATen/Dispatch.h @@ -6,7 +6,6 @@ #include #include #include -#include #ifdef __CUDACC__ #include // For CUDA_VERSION diff --git a/aten/src/ATen/MapAllocator.h b/aten/src/ATen/MapAllocator.h index fffa2893d06..9fc5e32adcb 100644 --- a/aten/src/ATen/MapAllocator.h +++ b/aten/src/ATen/MapAllocator.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace at { diff --git a/aten/src/ATen/PadNd.h b/aten/src/ATen/PadNd.h index e1e1370013c..9c0590bb945 100644 --- a/aten/src/ATen/PadNd.h +++ b/aten/src/ATen/PadNd.h @@ -1,6 +1,4 @@ #pragma once -#include -#include namespace at { diff --git a/aten/src/ATen/core/ATen_pch.h b/aten/src/ATen/core/ATen_pch.h index 57ca22bf437..f10c191a4c1 100644 --- a/aten/src/ATen/core/ATen_pch.h +++ b/aten/src/ATen/core/ATen_pch.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/aten/src/ATen/core/function_schema.h b/aten/src/ATen/core/function_schema.h index 48685c62d6c..c3e1520dc98 100644 --- a/aten/src/ATen/core/function_schema.h +++ b/aten/src/ATen/core/function_schema.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/aten/src/ATen/core/op_registration/op_allowlist.h b/aten/src/ATen/core/op_registration/op_allowlist.h index 9c673f3b436..e01c666ed82 100644 --- a/aten/src/ATen/core/op_registration/op_allowlist.h +++ b/aten/src/ATen/core/op_registration/op_allowlist.h @@ -25,7 +25,7 @@ * will fail (and the operator will be included in the binary anyway). */ -#include +#include #include #include @@ -36,7 +36,7 @@ namespace c10::impl { -constexpr bool allowlist_contains(string_view allowlist, string_view item); // Forward Declare +constexpr bool allowlist_contains(std::string_view allowlist, std::string_view item); // Forward Declare /** * In selective build mode returns true/false depending on whether a build @@ -102,14 +102,14 @@ constexpr bool is_build_feature_available(const char* name) { // returns true iff allowlist contains item // allowlist_contains("a;bc;d", "bc") == true -constexpr bool allowlist_contains(string_view allowlist, string_view item) { +constexpr bool allowlist_contains(std::string_view allowlist, std::string_view item) { //Choose a really big value for next so that if something goes wrong //this code will blow up in a hopefully detectable way. size_t next = std::numeric_limits::max(); for (size_t cur = 0; cur <= allowlist.size(); cur = next) { next = allowlist.find(';', cur); - if (next != string_view::npos) { - if (allowlist.substr(cur, next - cur).compare(item) == 0) { + if (next != std::string_view::npos) { + if (allowlist.substr(cur, next - cur) == item) { return true; } next++; @@ -125,12 +125,12 @@ constexpr bool allowlist_contains(string_view allowlist, string_view item) { // Returns true iff the given op name is on the allowlist // and should be registered -constexpr bool op_allowlist_check(string_view op_name [[maybe_unused]]) { - assert(op_name.find("::") != string_view::npos); +constexpr bool op_allowlist_check(std::string_view op_name [[maybe_unused]]) { + assert(op_name.find("::") != std::string_view::npos); // Use assert() instead of throw() due to a gcc bug. See: // https://stackoverflow.com/questions/34280729/throw-in-constexpr-function // https://github.com/fmtlib/fmt/issues/682 - assert(op_name.find("(") == string_view::npos); + assert(op_name.find('(') == std::string_view::npos); #if !defined(TORCH_OPERATOR_WHITELIST) // If the TORCH_OPERATOR_WHITELIST parameter is not defined, // all ops are to be registered @@ -150,21 +150,20 @@ constexpr bool op_allowlist_check(string_view op_name [[maybe_unused]]) { // Returns true iff the given schema string is on the allowlist // and should be registered -constexpr bool schema_allowlist_check(string_view schema) { +constexpr bool schema_allowlist_check(std::string_view schema) { #if defined(TORCH_FORCE_SCHEMA_REGISTRATION) return true; #else - return op_allowlist_check(schema.substr(0, schema.find("("))); + return op_allowlist_check(schema.substr(0, schema.find('('))); #endif } // Returns true iff the given custom class name is on the allowlist // and should be registered -constexpr bool custom_class_allowlist_check(string_view custom_class_name) { +constexpr bool custom_class_allowlist_check(std::string_view custom_class_name [[maybe_unused]]) { #if !defined(TORCH_CUSTOM_CLASS_ALLOWLIST) // If the TORCH_CUSTOM_CLASS_ALLOWLIST parameter is not defined, // all custom classes are to be registered - (void)custom_class_name; return true; #else return allowlist_contains( @@ -175,8 +174,8 @@ constexpr bool custom_class_allowlist_check(string_view custom_class_name) { // schema_allowlist_check() implicitly depends on a macro, TORCH_OPERATOR_WHITELIST. // Add this API to pass arbitrary allowlist. -constexpr bool op_allowlist_contains_name_in_schema(string_view allowlist, string_view schema) { - return allowlist_contains(allowlist, schema.substr(0, schema.find("("))); +constexpr bool op_allowlist_contains_name_in_schema(std::string_view allowlist, std::string_view schema) { + return allowlist_contains(allowlist, schema.substr(0, schema.find('('))); } // Returns true iff the given dispatch key is on the allowlist diff --git a/aten/src/ATen/core/operator_name.h b/aten/src/ATen/core/operator_name.h index cc03be357fb..22e1f427b63 100644 --- a/aten/src/ATen/core/operator_name.h +++ b/aten/src/ATen/core/operator_name.h @@ -2,12 +2,12 @@ #include #include -#include #include #include #include #include +#include #include namespace c10 { diff --git a/aten/src/ATen/native/BatchLinearAlgebra.h b/aten/src/ATen/native/BatchLinearAlgebra.h index 6254ba47707..1b8ce2bdf54 100644 --- a/aten/src/ATen/native/BatchLinearAlgebra.h +++ b/aten/src/ATen/native/BatchLinearAlgebra.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include #include #include diff --git a/aten/src/ATen/native/Gelu.h b/aten/src/ATen/native/Gelu.h index 2f330aa1869..9482e2161e2 100644 --- a/aten/src/ATen/native/Gelu.h +++ b/aten/src/ATen/native/Gelu.h @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace at::native { // These constants control the approximation behavior of gelu function. diff --git a/aten/src/ATen/native/nested/NestedTensorTransformerFunctions.cpp b/aten/src/ATen/native/nested/NestedTensorTransformerFunctions.cpp index 6c2b2ba3d56..5f2442f21d8 100644 --- a/aten/src/ATen/native/nested/NestedTensorTransformerFunctions.cpp +++ b/aten/src/ATen/native/nested/NestedTensorTransformerFunctions.cpp @@ -5,9 +5,9 @@ #include #include -#include #include #include +#include namespace at::native { namespace { diff --git a/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp b/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp index ea773314bc0..81297e49d53 100644 --- a/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp +++ b/aten/src/ATen/native/transformers/cuda/sdp_utils.cpp @@ -23,7 +23,6 @@ #endif #include -#include #if USE_ROCM #if defined(USE_FLASH_ATTENTION) || defined(USE_MEM_EFF_ATTENTION) diff --git a/aten/src/ATen/native/transformers/sdp_utils_cpp.h b/aten/src/ATen/native/transformers/sdp_utils_cpp.h index 16d882624dd..22afbac1d07 100644 --- a/aten/src/ATen/native/transformers/sdp_utils_cpp.h +++ b/aten/src/ATen/native/transformers/sdp_utils_cpp.h @@ -14,10 +14,10 @@ #include #include -#include #include #include #include +#include namespace sdp { diff --git a/aten/src/ATen/templates/Function.h b/aten/src/ATen/templates/Function.h index db430a3ffc4..73096afbf11 100644 --- a/aten/src/ATen/templates/Function.h +++ b/aten/src/ATen/templates/Function.h @@ -14,6 +14,7 @@ #include #include #include +#include ${static_dispatch_ops_headers} diff --git a/aten/src/ATen/templates/Operator.h b/aten/src/ATen/templates/Operator.h index 8b3989b66de..ed220f91729 100644 --- a/aten/src/ATen/templates/Operator.h +++ b/aten/src/ATen/templates/Operator.h @@ -2,6 +2,7 @@ // ${generated_comment} +#include #include #include diff --git a/aten/src/ATen/templates/TensorMethods.cpp b/aten/src/ATen/templates/TensorMethods.cpp index 033019bb82f..0504dccc385 100644 --- a/aten/src/ATen/templates/TensorMethods.cpp +++ b/aten/src/ATen/templates/TensorMethods.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include namespace at { diff --git a/c10/core/impl/alloc_cpu.cpp b/c10/core/impl/alloc_cpu.cpp index b252f28a751..0a891b07888 100644 --- a/c10/core/impl/alloc_cpu.cpp +++ b/c10/core/impl/alloc_cpu.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef USE_MIMALLOC #include diff --git a/c10/util/ConstexprCrc.h b/c10/util/ConstexprCrc.h index 3fd8f28feb2..4719def70e9 100644 --- a/c10/util/ConstexprCrc.h +++ b/c10/util/ConstexprCrc.h @@ -2,9 +2,9 @@ #include #include -#include #include #include +#include namespace c10::util { diff --git a/c10/util/StringUtil.h b/c10/util/StringUtil.h index 601535e42dc..c2b726a94d3 100644 --- a/c10/util/StringUtil.h +++ b/c10/util/StringUtil.h @@ -3,13 +3,13 @@ #include #include -#include #include #include #include #include #include +#include C10_CLANG_DIAGNOSTIC_PUSH() #if C10_CLANG_HAS_WARNING("-Wshorten-64-to-32") diff --git a/caffe2/serialize/inline_container.cc b/caffe2/serialize/inline_container.cc index 2554d25fd2a..ec993253340 100644 --- a/caffe2/serialize/inline_container.cc +++ b/caffe2/serialize/inline_container.cc @@ -16,6 +16,7 @@ #include #include #include +#include #include "caffe2/core/common.h" #include "caffe2/serialize/file_adapter.h" diff --git a/torch/csrc/utils/python_arg_parser.cpp b/torch/csrc/utils/python_arg_parser.cpp index b3ae16cdb13..5fbf972b2bc 100644 --- a/torch/csrc/utils/python_arg_parser.cpp +++ b/torch/csrc/utils/python_arg_parser.cpp @@ -48,6 +48,7 @@ static std::unordered_map type_map = { {"std::string", ParameterType::STRING}, {"c10::string_view", ParameterType::STRING}, {"std::string_view", ParameterType::STRING}, + {"::std::string_view", ParameterType::STRING}, {"Dimname", ParameterType::DIMNAME}, {"DimnameList", ParameterType::DIMNAME_LIST}, {"ScalarList", ParameterType::SCALAR_LIST},