clean static code

This commit is contained in:
chenfei 2023-02-09 19:29:33 +08:00
parent f33b9f7258
commit 137a2be018
13 changed files with 34 additions and 35 deletions

View File

@ -26,7 +26,7 @@
#include "frontend/operator/composite/zip_operation.h"
namespace mindspore {
namespace prim {
void RegCompositeOpsGroup(py::module *m) {
void RegCompositeOpsGroup(const py::module *m) {
// Reg HyperMap
(void)py::class_<HyperMapPy, MetaFuncGraph, std::shared_ptr<HyperMapPy>>(*m, "HyperMap_")
.def(py::init<bool, std::shared_ptr<MultitypeFuncGraph>>(), py::arg("reverse"), py::arg("ops"))

View File

@ -24,16 +24,16 @@
namespace py = pybind11;
namespace mindspore {
void RegTyping(py::module *m);
void RegCNode(py::module *m);
void RegCell(py::module *m);
void RegMetaFuncGraph(py::module *m);
void RegFuncGraph(py::module *m);
void RegCNode(const py::module *m);
void RegCell(const py::module *m);
void RegMetaFuncGraph(const py::module *m);
void RegFuncGraph(const py::module *m);
void RegUpdateFuncGraphHyperParams(py::module *m);
void RegParamInfo(py::module *m);
void RegPrimitive(py::module *m);
void RegSignatureEnumRW(py::module *m);
void RegValues(py::module *m);
void RegMsContext(py::module *m);
void RegParamInfo(const py::module *m);
void RegPrimitive(const py::module *m);
void RegSignatureEnumRW(const py::module *m);
void RegValues(const py::module *m);
void RegMsContext(const py::module *m);
void RegSecurity(py::module *m);
namespace initializer {
@ -45,22 +45,22 @@ void RegPyNativeExecutor(const py::module *m);
}
namespace tensor {
void RegMetaTensor(py::module *m);
void RegCSRTensor(py::module *m);
void RegCOOTensor(py::module *m);
void RegRowTensor(py::module *m);
void RegMapTensor(py::module *m);
void RegMetaTensor(const py::module *m);
void RegCSRTensor(const py::module *m);
void RegCOOTensor(const py::module *m);
void RegRowTensor(const py::module *m);
void RegMapTensor(const py::module *m);
} // namespace tensor
#ifndef ENABLE_SECURITY
namespace profiler {
void RegProfilerManager(py::module *m);
void RegProfiler(py::module *m);
void RegProfilerManager(const py::module *m);
void RegProfiler(const py::module *m);
} // namespace profiler
#endif
namespace prim {
void RegCompositeOpsGroup(py::module *m);
void RegCompositeOpsGroup(const py::module *m);
}
#ifdef _MSC_VER
namespace abstract {

View File

@ -73,7 +73,7 @@ using RecoveryContext = mindspore::distributed::recovery::RecoveryContext;
#ifndef ENABLE_SECURITY
namespace mindspore {
namespace profiler {
void RegProfiler(py::module *m) {
void RegProfiler(const py::module *m) {
(void)py::class_<Profiler, std::shared_ptr<Profiler>>(*m, "Profiler")
.def_static("get_instance", &Profiler::GetInstance, py::arg("device_name"), "Profiler get_instance.")
.def("init", &Profiler::Init, py::arg("profiling_path"), py::arg("device_id") = py::int_(0),
@ -86,7 +86,7 @@ void RegProfiler(py::module *m) {
.def("step_profiling_enable", &Profiler::StepProfilingEnable, py::arg("enable_flag"),
"enable or disable step profiling");
}
void RegProfilerManager(py::module *m) {
void RegProfilerManager(const py::module *m) {
(void)py::class_<ProfilerManager, std::shared_ptr<ProfilerManager>>(*m, "ProfilerManager")
.def_static("get_instance", &ProfilerManager::GetInstance, "ProfilerManager get_instance.")
.def("dynamic_status", &ProfilerManager::GetNetDynamicShapeStatus, "dynamic_status");

View File

@ -20,7 +20,7 @@
namespace mindspore {
// Define python 'CNode' class.
void RegCNode(py::module *m) {
void RegCNode(const py::module *m) {
(void)py::class_<CNode, CNodePtr>(*m, "CNode")
.def("expanded_str", (std::string(CNode::*)(int32_t) const) & CNode::DebugString,
"Get CNode string representation with specified expansion level.");

View File

@ -39,7 +39,7 @@ void CellPy::AddAttr(CellPtr cell, const std::string &name, const py::object &ob
}
}
// Define python 'Cell' class.
void RegCell(py::module *m) {
void RegCell(const py::module *m) {
(void)py::enum_<MixedPrecisionType>(*m, "MixedPrecisionType", py::arithmetic())
.value("NOTSET", MixedPrecisionType::kNotSet)
.value("FP16", MixedPrecisionType::kFP16)

View File

@ -60,7 +60,7 @@ py::dict UpdateFuncGraphHyperParams(const FuncGraphPtr &func_graph, const py::di
return hyper_params;
}
void RegFuncGraph(py::module *m) {
void RegFuncGraph(const py::module *m) {
// Define python "FuncGraph" class
(void)py::class_<FuncGraph, FuncGraphPtr>(*m, "FuncGraph")
.def(py::init())
@ -68,7 +68,7 @@ void RegFuncGraph(py::module *m) {
.def("get_return", &FuncGraph::get_return, "Get return node of FuncGraph");
}
void RegMetaFuncGraph(py::module *m) {
void RegMetaFuncGraph(const py::module *m) {
// Define python "MetaFuncGraph_" class
(void)py::class_<MetaFuncGraph, std::shared_ptr<MetaFuncGraph>>(*m, "MetaFuncGraph_")
.def("set_signatures", &MetaFuncGraph::set_signatures, "Set primitive inputs signature.");

View File

@ -94,7 +94,7 @@ static std::pair<tensor::TensorPtr, tensor::TensorPtr> PyMapTensorGetData(const
}
namespace tensor {
void RegMapTensor(py::module *m) {
void RegMapTensor(const py::module *m) {
// Define python MapTensor class.
(void)py::class_<MapTensor, MapTensorPtr>(*m, "MapTensor_")
.def(py::init([](const TypePtr &key_dtype, const TypePtr &value_dtype, const ShapeVector &value_shape,

View File

@ -20,7 +20,7 @@
namespace mindspore {
namespace py = pybind11;
void RegParamInfo(py::module *m) {
void RegParamInfo(const py::module *m) {
(void)py::class_<ParamInfo, ParamInfoPtr>(*m, "ParamInfo", py::dynamic_attr())
.def(py::init())
.def(py::init([](const ParamInfo &param_info) { return std::make_shared<ParamInfo>(param_info); }),

View File

@ -698,7 +698,7 @@ void PrimitivePyAdapter::set_attached_primitive(const PrimitivePyPtr &prim) {
attached_primitive_ = prim;
}
void RegPrimitive(py::module *m) {
void RegPrimitive(const py::module *m) {
(void)py::enum_<PrimType>(*m, "prim_type", py::arithmetic())
.value("unknown", PrimType::kPrimTypeUnknown)
.value("builtin", PrimType::kPrimTypeBuiltIn)

View File

@ -30,7 +30,7 @@ static ValuePtr PyArgToValue(const py::object &arg) {
return parse::data_converter::PyDataToValue(arg);
}
// Bind SignatureEnumRW as a python class.
void RegSignatureEnumRW(py::module *m) {
void RegSignatureEnumRW(const py::module *m) {
(void)py::class_<Signature>(*m, "Signature")
.def(py::init([](const std::string &name, SignatureEnumRW rw, SignatureEnumKind kind, const py::object arg_default,
SignatureEnumDType dtype) {

View File

@ -488,7 +488,7 @@ static ShapeVector GetShapeFromTuple(const py::tuple &tuple) {
}
return shape;
}
void RegMetaTensor(py::module *m) {
void RegMetaTensor(const py::module *m) {
// Define python MetaTensor class.
(void)py::class_<MetaTensor, std::shared_ptr<MetaTensor>>(*m, "MetaTensor")
.def(py::init<TypePtr, const ShapeVector>(), py::arg("dtype"), py::arg("shape"))
@ -788,7 +788,7 @@ py::tuple GetSparseTensorShape(const T &sparse_tensor) {
py::tuple CSRTensorPy::GetPyTupleShape(const CSRTensor &csr_tensor) { return GetSparseTensorShape(csr_tensor); }
void RegCSRTensor(py::module *m) {
void RegCSRTensor(const py::module *m) {
// Define python CSRTensor class.
(void)py::class_<CSRTensor, std::shared_ptr<CSRTensor>>(*m, "CSRTensor")
.def(py::init([](const Tensor &indptr, const Tensor &indices, const Tensor &values, const py::tuple &shape) {
@ -809,7 +809,7 @@ void RegCSRTensor(py::module *m) {
py::tuple COOTensorPy::GetPyTupleShape(const COOTensor &coo_tensor) { return GetSparseTensorShape(coo_tensor); }
void RegCOOTensor(py::module *m) {
void RegCOOTensor(const py::module *m) {
// Define python COOTensor class.
(void)py::class_<COOTensor, std::shared_ptr<COOTensor>>(*m, "COOTensor")
.def(py::init([](const Tensor &indices, const Tensor &values, const py::tuple &shape) {
@ -829,7 +829,7 @@ void RegCOOTensor(py::module *m) {
py::tuple RowTensorPy::GetPyTupleShape(const RowTensor &row_tensor) { return GetSparseTensorShape(row_tensor); }
void RegRowTensor(py::module *m) {
void RegRowTensor(const py::module *m) {
// Define python RowTensor class.
(void)py::class_<RowTensor, std::shared_ptr<RowTensor>>(*m, "RowTensor")
.def(py::init([](const Tensor &indices, const Tensor &values, const py::tuple &shape) {

View File

@ -15,14 +15,13 @@
*/
#include "ir/value.h"
#include <string>
#include "include/common/pybind_api/api_register.h"
#include "abstract/abstract_value.h"
namespace mindspore {
// Define python class for values.
void RegValues(py::module *m) {
void RegValues(const py::module *m) {
(void)py::class_<UMonad, std::shared_ptr<UMonad>>(*m, "UMonad").def(py::init());
(void)py::class_<IOMonad, std::shared_ptr<IOMonad>>(*m, "IOMonad").def(py::init());
}

View File

@ -72,7 +72,7 @@ py::object MsCtxGetParameter(const std::shared_ptr<MsContext> &ctx, MsCtxParam p
} // namespace
// Note: exported python enum variables beginning with '_' are for internal use
void RegMsContext(py::module *m) {
void RegMsContext(const py::module *m) {
(void)py::enum_<MsCtxParam>(*m, "ms_ctx_param", py::arithmetic())
.value("check_bprop", MsCtxParam::MS_CTX_CHECK_BPROP_FLAG)
.value("enable_dump", MsCtxParam::MS_CTX_ENABLE_DUMP)