diff --git a/aten/src/ATen/native/cpu/group_norm_kernel.cpp b/aten/src/ATen/native/cpu/group_norm_kernel.cpp index 8c1000f8de47..4807a689e8c2 100644 --- a/aten/src/ATen/native/cpu/group_norm_kernel.cpp +++ b/aten/src/ATen/native/cpu/group_norm_kernel.cpp @@ -570,10 +570,8 @@ ComputeInternalGradients( at::parallel_for(0, N * C, 1, [=](int64_t start, int64_t end) { constexpr int64_t K = Vec::size(); const int64_t inner_size = HxW / K * K; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) - std::array ds_arr; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) - std::array db_arr; + std::array ds_arr{}; + std::array db_arr{}; for (const auto i : c10::irange(start, end)) { const T* dY_ptr = dY + i * HxW; const T* X_ptr = X + i * HxW; diff --git a/torch/csrc/dynamo/guards.cpp b/torch/csrc/dynamo/guards.cpp index 6795857ed9f5..0b8dec86f98d 100644 --- a/torch/csrc/dynamo/guards.cpp +++ b/torch/csrc/dynamo/guards.cpp @@ -525,11 +525,11 @@ static PyTypeObject TensorGuardsType = { PyVarObject_HEAD_INIT(nullptr, 0) struct AutocastState { static constexpr auto& DEVICES = at::autocast::_AUTOCAST_SUPPORTED_DEVICES; - std::array enabled; - std::array dtype; + std::array enabled{}; + std::array dtype{}; bool cache_enabled; - AutocastState() : enabled{}, dtype{} { + AutocastState() { for (size_t i = 0; i < DEVICES.size(); i++) { enabled[i] = at::autocast::is_autocast_enabled(DEVICES[i]); dtype[i] = at::autocast::get_autocast_dtype(DEVICES[i]); @@ -1977,8 +1977,7 @@ class SYMBOLIC_SHAPE_GUARD : public RelationalGuard { py::object py_addr_keep_alive, py::object verbose_code_parts) : RelationalGuard(std::move(verbose_code_parts)), - _py_addr_keep_alive(std::move(py_addr_keep_alive)), - _args_seen{0} { + _py_addr_keep_alive(std::move(py_addr_keep_alive)) { _nargs_int = PyLong_AsSize_t(nargs_int.ptr()); _nargs_float = PyLong_AsSize_t(nargs_float.ptr()); _nargs = _nargs_int + _nargs_float; @@ -2072,7 +2071,7 @@ class SYMBOLIC_SHAPE_GUARD : public RelationalGuard { private: py::object _py_addr_keep_alive; - size_t _args_seen, _nargs_float, _nargs_int, _nargs; + size_t _args_seen{0}, _nargs_float, _nargs_int, _nargs; std::vector _args_int; std::vector _args_float; std::function _guard_check_fn; @@ -3496,7 +3495,6 @@ class GetAttrGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GetAttrGuardAccessor(GuardManager* guard_manager, GetAttrGuardAccessor* from) : GuardAccessor(guard_manager, from) { from->clone_visitor(this); @@ -3515,7 +3513,7 @@ class GetAttrGuardAccessor : public GuardAccessor { private: // no need of py::object here because the attr_name is already passed on to // the base class as accessor_key which is a py::object. - PyObject* _attr_name; + PyObject* _attr_name{nullptr}; }; /** @@ -3571,7 +3569,6 @@ class GetGenericDictGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GetGenericDictGuardAccessor( GuardManager* guard_manager, GetGenericDictGuardAccessor* from) @@ -3639,7 +3636,6 @@ class GetItemGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GetItemGuardAccessor(GuardManager* guard_manager, GetItemGuardAccessor* from) : GuardAccessor(guard_manager, from) { from->clone_visitor(this); @@ -3658,7 +3654,7 @@ class GetItemGuardAccessor : public GuardAccessor { private: // no need of py::object here because the attr_name is already passed on to // the base class as accessor_key which is a py::object. - PyObject* _attr_name; + PyObject* _attr_name{nullptr}; }; /** @@ -3757,7 +3753,6 @@ class FrameLocalsGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) FrameLocalsGuardAccessor( GuardManager* guard_manager, FrameLocalsGuardAccessor* from) @@ -3778,12 +3773,12 @@ class FrameLocalsGuardAccessor : public GuardAccessor { } private: - PyObject* _key; - int _framelocals_idx; + PyObject* _key{nullptr}; + int _framelocals_idx{-1}; // If immutable object and dict tag matches, we can skip the guard subtree and // return true. - bool _is_immutable_object; + bool _is_immutable_object{false}; }; /** @@ -3847,7 +3842,6 @@ class DictGetItemGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) DictGetItemGuardAccessor( GuardManager* guard_manager, DictGetItemGuardAccessor* from) @@ -3867,11 +3861,11 @@ class DictGetItemGuardAccessor : public GuardAccessor { } private: - PyObject* _key; + PyObject* _key{nullptr}; // If immutable object and dict tag matches, we can skip the guard subtree and // return true. - bool _is_immutable_object; + bool _is_immutable_object{false}; }; /** @@ -3924,7 +3918,6 @@ class ListGetItemGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) ListGetItemGuardAccessor( GuardManager* guard_manager, ListGetItemGuardAccessor* from) @@ -3943,7 +3936,7 @@ class ListGetItemGuardAccessor : public GuardAccessor { } private: - Py_ssize_t _index; + Py_ssize_t _index{-1}; }; /** @@ -3996,7 +3989,6 @@ class TupleGetItemGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) TupleGetItemGuardAccessor( GuardManager* guard_manager, TupleGetItemGuardAccessor* from) @@ -4016,7 +4008,7 @@ class TupleGetItemGuardAccessor : public GuardAccessor { } private: - Py_ssize_t _index; + Py_ssize_t _index{-1}; }; enum class TensorProperty { @@ -4143,7 +4135,6 @@ class TensorPropertyGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) TensorPropertyGuardAccessor( GuardManager* guard_manager, TensorPropertyGuardAccessor<_prop>* from) @@ -4163,7 +4154,7 @@ class TensorPropertyGuardAccessor : public GuardAccessor { } private: - Py_ssize_t _index; + Py_ssize_t _index{-1}; }; /** @@ -4210,7 +4201,6 @@ class IndexedGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) IndexedGuardAccessor(GuardManager* guard_manager, IndexedGuardAccessor* from) : GuardAccessor(guard_manager, from) { from->clone_visitor(this); @@ -4227,7 +4217,7 @@ class IndexedGuardAccessor : public GuardAccessor { } private: - py::int_ _index; + py::int_ _index{-1}; }; /** @@ -4287,7 +4277,6 @@ class GradGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GradGuardAccessor(GuardManager* guard_manager, GradGuardAccessor* from) : GuardAccessor(guard_manager, from) { from->clone_visitor(this); @@ -4361,7 +4350,6 @@ class FuncDefaultsGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) FuncDefaultsGuardAccessor( GuardManager* guard_manager, FuncDefaultsGuardAccessor* from) @@ -4437,7 +4425,6 @@ class FuncKwDefaultsGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) FuncKwDefaultsGuardAccessor( GuardManager* guard_manager, FuncKwDefaultsGuardAccessor* from) @@ -4494,7 +4481,6 @@ class GlobalsGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GlobalsGuardAccessor(GuardManager* guard_manager, GlobalsGuardAccessor* from) : GuardAccessor(guard_manager, from) { from->clone_visitor(this); @@ -4513,7 +4499,7 @@ class GlobalsGuardAccessor : public GuardAccessor { private: // no need of py::object here because the globals_dict is already passed on to // the base class as accessor_key which is a py::object. - PyObject* _globals_dict; + PyObject* _globals_dict{nullptr}; }; /** @@ -4554,7 +4540,6 @@ class TypeGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) TypeGuardAccessor(GuardManager* guard_manager, TypeGuardAccessor* from) : GuardAccessor(guard_manager, from) { from->clone_visitor(this); @@ -4623,7 +4608,6 @@ class TupleIteratorGetItemAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) TupleIteratorGetItemAccessor( GuardManager* guard_manager, TupleIteratorGetItemAccessor* from) @@ -4643,7 +4627,7 @@ class TupleIteratorGetItemAccessor : public GuardAccessor { } private: - Py_ssize_t _index; + Py_ssize_t _index{-1}; }; /** @@ -4739,7 +4723,6 @@ class GlobalWeakRefGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GlobalWeakRefGuardAccessor( GuardManager* guard_manager, GlobalWeakRefGuardAccessor* from) @@ -4758,7 +4741,7 @@ class GlobalWeakRefGuardAccessor : public GuardAccessor { } private: - PyObject* _global_name; + PyObject* _global_name{nullptr}; }; /** @@ -4830,7 +4813,6 @@ class WeakRefCallGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) WeakRefCallGuardAccessor( GuardManager* guard_manager, WeakRefCallGuardAccessor* from) @@ -4910,7 +4892,6 @@ class CallFunctionNoArgsGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) CallFunctionNoArgsGuardAccessor( GuardManager* guard_manager, CallFunctionNoArgsGuardAccessor* from) @@ -4982,7 +4963,6 @@ class PythonLambdaGuardAccessor : public GuardAccessor { } public: // cloning functions - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) PythonLambdaGuardAccessor( GuardManager* guard_manager, PythonLambdaGuardAccessor* from) diff --git a/torch/csrc/jit/codegen/fuser/arg_spec.h b/torch/csrc/jit/codegen/fuser/arg_spec.h index 7239e0391b8f..923aa324aa7a 100644 --- a/torch/csrc/jit/codegen/fuser/arg_spec.h +++ b/torch/csrc/jit/codegen/fuser/arg_spec.h @@ -16,7 +16,6 @@ namespace torch::jit::fuser { // Note: the device to run on is included in the arg spec because kernels // are compiled per-device. struct TORCH_API ArgSpec { - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) ArgSpec(at::TensorList inputs, const int _device) : descs_{c10::fmap(inputs)}, hash_code_{c10::get_hash(_device, inputs.size(), descs_)}, diff --git a/torch/csrc/jit/ir/attributes.h b/torch/csrc/jit/ir/attributes.h index fb2c44350d2d..f6e8f2148078 100644 --- a/torch/csrc/jit/ir/attributes.h +++ b/torch/csrc/jit/ir/attributes.h @@ -86,7 +86,6 @@ template struct VectorAttributeValue : public AttributeValue { using ConstructorType = std::vector; using ValueType = std::vector; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) VectorAttributeValue(Symbol name, ConstructorType value_) : AttributeValue(name), value_(std::move(value_)) {} ValueType& value() { @@ -144,7 +143,6 @@ struct TORCH_API GraphAttr : public AttributeValue { struct TORCH_API GraphsAttr : public AttributeValue { using ConstructorType = std::vector>; using ValueType = std::vector>; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) GraphsAttr(Symbol name, ConstructorType value_) : AttributeValue(name), value_(std::move(value_)) {} ValueType& value() { diff --git a/torch/csrc/jit/ir/ir.h b/torch/csrc/jit/ir/ir.h index 44087074e891..fc780c26c3dd 100644 --- a/torch/csrc/jit/ir/ir.h +++ b/torch/csrc/jit/ir/ir.h @@ -1490,7 +1490,6 @@ struct WithCurrentScope { ScopePtr prev_scope_; }; -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) inline Value::Value(Node* node_, size_t offset_) : node_(node_), offset_(offset_), @@ -1651,7 +1650,6 @@ struct TORCH_API OperatorSet { }; template -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct OperatorMap { // Type aliasing using OpMapType = typename std::pair, T>; @@ -1659,12 +1657,10 @@ struct OperatorMap { using MapType = std::unordered_map; OperatorMap() = default; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) explicit OperatorMap( std::initializer_list, T>> init) { insert(init); } - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) explicit OperatorMap(std::initializer_list> init) { insert(init); } @@ -1760,7 +1756,6 @@ struct OperatorMap { }; template -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct FunctionSchemaMap { // Type aliasing using FuncSchemaMapType = typename std::pair; diff --git a/torch/csrc/jit/runtime/graph_executor.h b/torch/csrc/jit/runtime/graph_executor.h index 8295b9d6c378..d1039216de3e 100644 --- a/torch/csrc/jit/runtime/graph_executor.h +++ b/torch/csrc/jit/runtime/graph_executor.h @@ -43,7 +43,6 @@ struct ExecutionPlan { // They are only valid only right after you call getDebugState() and should // never be used again once another GraphExecutor function is called. -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct GraphExecutorState { const Graph* graph = nullptr; ExecutionPlan fallback; // XXX: members of this field are optional diff --git a/torch/csrc/jit/runtime/interpreter.h b/torch/csrc/jit/runtime/interpreter.h index e6a71dc0a0b9..6ae9f52a0cda 100644 --- a/torch/csrc/jit/runtime/interpreter.h +++ b/torch/csrc/jit/runtime/interpreter.h @@ -111,7 +111,6 @@ struct Suspend : public std::exception { return "Suspend"; } - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) explicit Suspend(c10::intrusive_ptr future_) : future(std::move(future_)) {} diff --git a/torch/csrc/jit/runtime/operator.h b/torch/csrc/jit/runtime/operator.h index 2e609f18ecc0..bde3825f5ea3 100644 --- a/torch/csrc/jit/runtime/operator.h +++ b/torch/csrc/jit/runtime/operator.h @@ -60,7 +60,6 @@ const std::array kJitOnlyOperatorTags = { // the concrete operator nature. struct TORCH_API Operator { private: - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct C10Operator final { c10::OperatorHandle handle_; Operation op_; @@ -69,7 +68,6 @@ struct TORCH_API Operator { std::string schema_string_; mutable std::optional alias_analysis_; }; - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct JitOnlyOperator final { // The only valid transition for schema_ is from right->left, i.e. // when the schema gets parsed. diff --git a/torch/csrc/jit/runtime/static/impl.cpp b/torch/csrc/jit/runtime/static/impl.cpp index ec736d006be0..0e2a89544b56 100644 --- a/torch/csrc/jit/runtime/static/impl.cpp +++ b/torch/csrc/jit/runtime/static/impl.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #ifdef FBCODE_CAFFE2 #include @@ -953,11 +952,11 @@ BlockRunner::BlockRunner( } } -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) BlockRunner::BlockRunner(BlockRunner&&) noexcept = default; BlockRunner::~BlockRunner() = default; +// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) void BlockRunner::set_arg(const size_t idx, std::vector&& args) { DCHECK(idx < args.size()); Input(idx + first_input_is_self_) = std::move(args[idx]); diff --git a/torch/csrc/jit/runtime/static/impl.h b/torch/csrc/jit/runtime/static/impl.h index 04a0862f9795..e8a3bdbc42ff 100644 --- a/torch/csrc/jit/runtime/static/impl.h +++ b/torch/csrc/jit/runtime/static/impl.h @@ -815,10 +815,8 @@ class TORCH_API BlockRunner { std::vector nodes_; }; -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) class TORCH_API StaticNodeInfo { public: - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) StaticNodeInfo( Node* n, ProcessedFunction* fn, @@ -873,6 +871,9 @@ class TORCH_API ProcessedNodeMetadata { // if the contained type (BlockRunner) is not copyable ProcessedNodeMetadata(const ProcessedNodeMetadata&) = delete; ProcessedNodeMetadata& operator=(const ProcessedNodeMetadata&) = delete; + ProcessedNodeMetadata(ProcessedNodeMetadata&&) = delete; + ProcessedNodeMetadata&& operator=(ProcessedNodeMetadata&&) = delete; + ~ProcessedNodeMetadata() = default; std::vector& block_runners() { return block_runners_; @@ -895,10 +896,8 @@ class TORCH_API ProcessedNodeMetadata { torch::jit::TaskLauncher* launcher_; }; -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) class TORCH_API ProcessedNode { public: - // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) ProcessedNode() = default; ProcessedNode(const StaticNodeInfo& other, IValue* values) @@ -917,6 +916,7 @@ class TORCH_API ProcessedNode { ProcessedNode(const ProcessedNode&) = delete; ProcessedNode& operator=(const ProcessedNode& other) = delete; ProcessedNode& operator=(ProcessedNode&&) = default; + ~ProcessedNode() = default; void run(); @@ -1025,10 +1025,10 @@ class TORCH_API ProcessedNode { [[nodiscard]] bool verify_inputs_dont_overlap_outputs(bool force_check) const; - Node* node_; - const ProcessedFunction* fn_; + Node* node_{nullptr}; + const ProcessedFunction* fn_{nullptr}; ProcessedNodeInputs inputs_; - uint16_t outputs_offset_; + uint16_t outputs_offset_{0}; bool overlap_detected_{false}; IValue* values_ = nullptr; // unowned // Metadata for ProcessedNode. diff --git a/torch/csrc/jit/runtime/static/ops.cpp b/torch/csrc/jit/runtime/static/ops.cpp index 60fca2f87066..d5586a5b9cd7 100644 --- a/torch/csrc/jit/runtime/static/ops.cpp +++ b/torch/csrc/jit/runtime/static/ops.cpp @@ -1344,7 +1344,6 @@ REGISTER_OPERATOR_FUNCTOR(aten::pow, aten_pow, [](Node* n) -> SROperator { namespace { -// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init) struct ToArgs { std::optional dtype; c10::Layout layout;