diff --git a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc index 2f43c7c0cd..718c95a653 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc +++ b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc @@ -284,17 +284,13 @@ bool ConvertOtherObj(py::object obj, ValuePtr *const data) { return false; } -bool ConvertIntegerWithType(const int &obj, ValuePtr *const data, TypePtr dtype = nullptr) { - if (dtype == nullptr) { - *data = std::make_shared(obj); - return true; - } - +template +bool ConvertNumberWithType(const T &obj, ValuePtr *const data, TypePtr dtype) { auto int_dypte = dyn_cast(dtype); if (int_dypte != nullptr) { switch (int_dypte->nbits()) { case 8: - *data = std::make_shared(static_cast(obj)); + *data = std::make_shared(obj); break; case 16: *data = std::make_shared(obj); @@ -312,7 +308,7 @@ bool ConvertIntegerWithType(const int &obj, ValuePtr *const data, TypePtr dtype } auto uint_dypte = dyn_cast(dtype); - if (int_dypte != nullptr) { + if (uint_dypte != nullptr) { switch (uint_dypte->nbits()) { case 8: *data = std::make_shared(obj); @@ -350,28 +346,22 @@ bool ConvertIntegerWithType(const int &obj, ValuePtr *const data, TypePtr dtype return false; } -bool ConvertFloatWithType(const float &obj, ValuePtr *const data, TypePtr dtype = nullptr) { +bool ConvertIntegerWithType(const int &obj, ValuePtr *const data, TypePtr dtype = nullptr) { if (dtype == nullptr) { - *data = std::make_shared(obj); + *data = std::make_shared(obj); return true; } - auto float_dypte = dyn_cast(dtype); - if (float_dypte == nullptr) { - return false; - } + return ConvertNumberWithType(obj, data, dtype); +} - switch (float_dypte->nbits()) { - case 32: - *data = std::make_shared(obj); - break; - case 64: - *data = std::make_shared(obj); - break; - default: - *data = std::make_shared(obj); +bool ConvertFloatWithType(const float &obj, ValuePtr *const data, TypePtr dtype = nullptr) { + if (dtype == nullptr) { + *data = std::make_shared(obj); + return true; } - return true; + + return ConvertNumberWithType(obj, data, dtype); } } // namespace diff --git a/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc b/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc index 4931069b52..fcd9781fac 100644 --- a/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc +++ b/mindspore/ccsrc/pybind_api/utils/ms_context_py.cc @@ -80,7 +80,6 @@ REGISTER_PYBIND_DEFINE(MsContextPy, ([](const py::module *m) { .value("enable_gpu_summary", MsCtxParam::MS_CTX_ENABLE_GPU_SUMMARY) .value("enable_graph_kernel", MsCtxParam::MS_CTX_ENABLE_GRAPH_KERNEL) .value("enable_hccl", MsCtxParam::MS_CTX_ENABLE_HCCL) - .value("enable_loop_sink", MsCtxParam::MS_CTX_ENABLE_LOOP_SINK) .value("enable_mem_reuse", MsCtxParam::MS_CTX_ENABLE_MEM_REUSE) .value("enable_pynative_hook", MsCtxParam::MS_CTX_ENABLE_PYNATIVE_HOOK) .value("enable_pynative_infer", MsCtxParam::MS_CTX_ENABLE_PYNATIVE_INFER)