From ffff36f66d33ff8e7899240f274d241fd1eb6779 Mon Sep 17 00:00:00 2001 From: xuxusheng Date: Fri, 28 Jul 2023 16:59:00 +0800 Subject: [PATCH] fix lint --- ccsrc/include/core/numba_wrapper.h | 3 +-- .../simulator/vector/detail/cpu_vector_avx_double_policy.h | 1 - ccsrc/python/device/include/python/device/binding.h | 2 ++ ccsrc/python/math/include/python/python_tensor.h | 2 ++ ccsrc/python/math/lib/bind_math.cpp | 6 ++++-- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ccsrc/include/core/numba_wrapper.h b/ccsrc/include/core/numba_wrapper.h index c83a94695..e9060e181 100644 --- a/ccsrc/include/core/numba_wrapper.h +++ b/ccsrc/include/core/numba_wrapper.h @@ -32,8 +32,7 @@ struct NumbaMatFunWrapper { using mat_t = void (*)(double, std::complex*); NumbaMatFunWrapper() = default; NumbaMatFunWrapper(uint64_t addr, int dim, tensor::TDtype dtype = tensor::TDtype::Complex128) - : dim(dim), dtype(dtype) { - fun = reinterpret_cast(addr); + : fun(reinterpret_cast(addr)), dim(dim), dtype(dtype) { } auto operator()(double coeff) const { diff --git a/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h b/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h index b3dc3546c..54b0e6780 100644 --- a/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h +++ b/ccsrc/include/simulator/vector/detail/cpu_vector_avx_double_policy.h @@ -17,7 +17,6 @@ #define INCLUDE_VECTOR_DETAIL_CPU_VECTOR_AVX_DOUBLE_POLICY_HPP #include -#include "simulator/alignedallocator.h" #include "simulator/cintrin.h" #include "simulator/vector/detail/cpu_vector_policy.h" #define INTRIN_M2_dot_V2(ket, i, j, mm, mmt, res) \ diff --git a/ccsrc/python/device/include/python/device/binding.h b/ccsrc/python/device/include/python/device/binding.h index bffbe6d5a..ba0b7b3b7 100644 --- a/ccsrc/python/device/include/python/device/binding.h +++ b/ccsrc/python/device/include/python/device/binding.h @@ -41,6 +41,7 @@ namespace py = pybind11; using namespace pybind11::literals; // NOLINT(build/namespaces_literals) namespace mm = mindquantum::mapping; +namespace { void BindTopology(py::module &module) { // NOLINT(runtime/references) auto qnode_module = py::class_>(module, "QubitNode") @@ -128,4 +129,5 @@ void BindQubitMapping(py::module &module) { // NOLINT(runtime/references) "Solve qubit mapping problem with saber method."); saber_m.doc() = "SABER method to implement qubit mapping task."; } +} // namespace #endif diff --git a/ccsrc/python/math/include/python/python_tensor.h b/ccsrc/python/math/include/python/python_tensor.h index 868d14449..ff37accde 100644 --- a/ccsrc/python/math/include/python/python_tensor.h +++ b/ccsrc/python/math/include/python/python_tensor.h @@ -23,6 +23,7 @@ #include "math/tensor/ops_cpu/memory_operator.h" #include "math/tensor/tensor.h" +namespace { template tensor::Tensor from_numpy(const pybind11::array_t &arr) { pybind11::buffer_info buf = arr.request(); @@ -31,4 +32,5 @@ tensor::Tensor from_numpy(const pybind11::array_t &arr) { } return tensor::ops::cpu::copy>(buf.ptr, buf.size); } +} // namespace #endif /* PYTHON_TENSOR_HPP_ */ diff --git a/ccsrc/python/math/lib/bind_math.cpp b/ccsrc/python/math/lib/bind_math.cpp index 9d32d71d6..3fb1fb843 100644 --- a/ccsrc/python/math/lib/bind_math.cpp +++ b/ccsrc/python/math/lib/bind_math.cpp @@ -60,6 +60,7 @@ using namespace pybind11::literals; // NOLINT(build/namespaces_literals) .def(std::complex() op py::self) \ .def(std::complex() op py::self) +namespace { void BindTensor(py::module &module) { // NOLINT(runtime/references) py::class_>(module, "Tensor", py::buffer_protocol()) .def(py::init<>()) @@ -111,8 +112,6 @@ void BindTensor(py::module &module) { // NOLINT(runtime/references) .def(py::init>> &, tensor::TDevice>(), "m"_a, "device"_a = tensor::TDevice::CPU); } -#undef BIND_TENSOR_OPS -#undef BIND_TENSOR_OPS_REV void BindPR(py::module &module) { // NOLINT(runtime/references) namespace pr = parameter; @@ -303,6 +302,9 @@ void BindTransform(py::module &module) { // NOLINT(runtime/references) module.def("ternary_tree", &operators::transform::ternary_tree, "ops"_a, "n_qubits"_a); module.def("bravyi_kitaev_superfast", &operators::transform::bravyi_kitaev_superfast, "ops"_a); } +} // namespace +#undef BIND_TENSOR_OPS +#undef BIND_TENSOR_OPS_REV PYBIND11_MODULE(_math, m) { m.doc() = "MindQuantum Math module.";