diff --git a/c10/core/ConstantSymNodeImpl.h b/c10/core/ConstantSymNodeImpl.h index 0e8c4a03de9e..931265cd6fcf 100644 --- a/c10/core/ConstantSymNodeImpl.h +++ b/c10/core/ConstantSymNodeImpl.h @@ -1,5 +1,5 @@ #include -#include +#include namespace c10 { @@ -39,11 +39,11 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl { } int64_t int_() override { TORCH_CHECK(is_int(), "not an int"); - return c10::get(value_); + return std::get(value_); } bool bool_() override { TORCH_CHECK(is_bool(), "not a bool"); - return c10::get(value_); + return std::get(value_); } bool has_hint() override { return true; @@ -56,21 +56,21 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl { c10::SymNode gt(const c10::SymNode& other) override; std::string str() override { if constexpr (is_int_()) { - return std::to_string(c10::get(value_)); + return std::to_string(std::get(value_)); } else { - return c10::get(value_) ? "true" : "false"; + return std::get(value_) ? "true" : "false"; } } c10::optional constant_int() override { if constexpr (is_int_()) { - return c10::get(value_); + return std::get(value_); } else { return c10::nullopt; } } c10::optional constant_bool() override { if constexpr (is_bool_()) { - return c10::get(value_); + return std::get(value_); } else { return c10::nullopt; } @@ -83,7 +83,7 @@ class C10_API ConstantSymNodeImpl : public SymNodeImpl { } private: - c10::variant value_; + std::variant value_; static constexpr bool is_int_() { return std::is_same::value; diff --git a/torch/csrc/autograd/profiler_kineto.cpp b/torch/csrc/autograd/profiler_kineto.cpp index d7d340f8b49b..3021458c8c05 100644 --- a/torch/csrc/autograd/profiler_kineto.cpp +++ b/torch/csrc/autograd/profiler_kineto.cpp @@ -100,7 +100,7 @@ auto parseArgData( std::vector concrete_inputs_list; for (const auto& i : c10::irange(input_shapes.size())) { - c10::visit( + std::visit( c10::overloaded( [&](const TensorMetadata& t) { shapes[i] = t.sizes_; @@ -127,12 +127,12 @@ auto parseArgData( concrete_inputs_list.resize(input_shapes.size()); for (const auto& i : c10::irange(input_shapes.size())) { - c10::visit( + std::visit( c10::overloaded( [&](const c10::IValue& val) { concrete_inputs_list[i] = val; }, [&](const auto&) {}), input_shapes[i]); - c10::visit( + std::visit( c10::overloaded( [&](const c10::IValue& val) { concrete_inputs_list[i] = val; diff --git a/torch/csrc/profiler/collection.h b/torch/csrc/profiler/collection.h index 20ef0c85836e..f998c88b15c9 100644 --- a/torch/csrc/profiler/collection.h +++ b/torch/csrc/profiler/collection.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -85,7 +86,7 @@ struct TORCH_API TensorMetadata : public RawTensorMetadataBase { c10::optional allocation_id_; }; -using op_input_t = c10::variant< +using op_input_t = std::variant< TensorMetadata, std::vector, c10::IValue, diff --git a/torch/csrc/profiler/data_flow.cpp b/torch/csrc/profiler/data_flow.cpp index dcb3eaffd439..d2c5b6a768e6 100644 --- a/torch/csrc/profiler/data_flow.cpp +++ b/torch/csrc/profiler/data_flow.cpp @@ -77,7 +77,7 @@ void calculateUniqueTensorIDs( result->visit(c10::overloaded( [&](ExtraFields& torch_op) { for (auto& i : torch_op.inputs_) { - c10::visit(raw_tensors, i); + std::visit(raw_tensors, i); } }, [&](ExtraFields& py_call) { diff --git a/torch/csrc/profiler/python/init.cpp b/torch/csrc/profiler/python/init.cpp index 14eb91c64f88..33b3e0f01f64 100644 --- a/torch/csrc/profiler/python/init.cpp +++ b/torch/csrc/profiler/python/init.cpp @@ -37,7 +37,7 @@ static void THPCapturedTraceback_dealloc(PyObject* self_) { PyTypeObject THPCapturedTracebackType = { PyVarObject_HEAD_INIT( - NULL, + nullptr, 0) "torch._C._profiler.CapturedTraceback", /* tp_name */ sizeof(THPCapturedTraceback), /* tp_basicsize */ 0, /* tp_itemsize */ @@ -162,7 +162,12 @@ int RecordFunctionFast_init( constexpr const char* kwlist[] = {"name", nullptr}; PyObject* name = nullptr; if (!PyArg_ParseTupleAndKeywords( - args, kwargs, "O", const_cast(kwlist), &name)) { + args, + kwargs, + "O", + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast) + const_cast(kwlist), + &name)) { return -1; } if (name) { @@ -383,7 +388,7 @@ void initPythonBindings(PyObject* module) { [](const torch_op_t& op) { py::list out; for (const auto& input : op.inputs_) { - c10::visit( + std::visit( c10::overloaded( [&](const c10::IValue& v) { out.append(torch::jit::toPyObject(v)); @@ -536,11 +541,11 @@ void initPythonBindings(PyObject* module) { static PyMethodDef RecordFunctionFast_methods[] = { {"__enter__", RecordFunctionFast_enter, METH_NOARGS, nullptr}, {"__exit__", RecordFunctionFast_exit, METH_VARARGS, nullptr}, - {NULL}, + {nullptr}, }; static PyTypeObject RecordFunctionFast_Type = { - PyVarObject_HEAD_INIT(NULL, 0)}; + PyVarObject_HEAD_INIT(nullptr, 0)}; RecordFunctionFast_Type.tp_name = "torch._C._profiler.RecordFunctionFast", RecordFunctionFast_Type.tp_basicsize = sizeof(RecordFunctionFast);