diff --git a/mindspore/ccsrc/pipeline/jit/init.cc b/mindspore/ccsrc/pipeline/jit/init.cc index 65adebb6e2..5f98341c79 100644 --- a/mindspore/ccsrc/pipeline/jit/init.cc +++ b/mindspore/ccsrc/pipeline/jit/init.cc @@ -81,9 +81,7 @@ PYBIND11_MODULE(_c_expression, m) { .def("has_compiled", &ExecutorPy::HasCompiled, py::arg("phase") = py::str(""), "get if cell compiled.") .def("run_init_graph", &ExecutorPy::RunInitGraph, "Run init Graph."); - (void)py::class_>(m, "EnvInstance_") - .def_readonly(mindspore::PYTHON_ENVINSTANCE_FLAG, &mindspore::EnvInstance::parse_info_) - .def(py::init()); + (void)py::class_>(m, "EnvInstance_").def(py::init()); (void)m.def("generate_key", &mindspore::pipeline::GenerateKey, "Generate the function graph key."); (void)m.def("real_run_op", &mindspore::pynative::RunOp, "Run op pynatively."); diff --git a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc index eb8444c485..ae68bf97c7 100644 --- a/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc +++ b/mindspore/ccsrc/pipeline/jit/parse/data_converter.cc @@ -361,15 +361,15 @@ bool ConvertData(const py::object &obj, ValuePtr *const data, bool use_signature ConvertDataClass(obj, &converted); } else if (py::hasattr(obj, PYTHON_PRIMITIVE_FLAG)) { ret = ConvertPrimitive(obj, &converted, use_signature); - } else if (py::hasattr(obj, PYTHON_METAFUNCGRAPH_FLAG)) { + } else if (py::isinstance(obj)) { ret = ConvertMetaFuncGraph(obj, &converted, use_signature); - } else if (py::hasattr(obj, PYTHON_DTYPE_FLAG)) { + } else if (py::isinstance(obj)) { ret = ConvertDataType(obj, &converted); - } else if (py::hasattr(obj, PYTHON_TENSOR_FLAG)) { + } else if (py::isinstance(obj)) { ret = ConvertTensor(obj, &converted); - } else if (py::hasattr(obj, PYTHON_META_TENSOR_FLAG)) { + } else if (py::isinstance(obj)) { ret = ConvertMetaTensor(obj, &converted); - } else if (py::hasattr(obj, PYTHON_ENVINSTANCE_FLAG)) { + } else if (py::isinstance(obj)) { std::shared_ptr env = obj.cast>(); converted = env; } else if (py::hasattr(obj, PYTHON_CLASS_MEMBER_NAMESPACE)) { diff --git a/mindspore/ccsrc/pipeline/jit/pipeline.cc b/mindspore/ccsrc/pipeline/jit/pipeline.cc index 76e1ad53a5..b1c3f2db03 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline.cc @@ -125,7 +125,7 @@ py::bool_ VerifyInputSignature(const py::list input_signature, const py::tuple i size_t count = 0; for (auto arg_obj : inputs) { - if (py::hasattr(arg_obj, PYTHON_TENSOR_FLAG)) { + if (py::isinstance(arg_obj)) { MS_LOG(DEBUG) << "Verify Tensor"; std::shared_ptr m_tensor = arg_obj.cast>(); if (m_tensor == nullptr) { diff --git a/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc b/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc index e08af4f2dc..dade1ada38 100644 --- a/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc +++ b/mindspore/ccsrc/pipeline/jit/pipeline_ge.cc @@ -161,7 +161,7 @@ void ConvertObjectToTensors(const py::dict &dict, TensorOrderMap *const tensors) // convert int to tensor with shape([1]) tensor = std::make_shared(kNumberTypeInt32, std::vector({1})); *(static_cast(tensor->data_c())) = py::cast(item.second.attr("default_input")); - } else if (py::hasattr(item.second.attr("default_input"), PYTHON_TENSOR_FLAG)) { + } else if (py::isinstance(item.second.attr("default_input"))) { // cast tensor tensor = py::cast>(item.second.attr("default_input")); } diff --git a/mindspore/ccsrc/pybind_api/export_flags.cc b/mindspore/ccsrc/pybind_api/export_flags.cc index bbec26ee99..a9953debdc 100644 --- a/mindspore/ccsrc/pybind_api/export_flags.cc +++ b/mindspore/ccsrc/pybind_api/export_flags.cc @@ -18,11 +18,6 @@ namespace mindspore { const char PYTHON_PRIMITIVE_FLAG[] = "__primitive_flag__"; -const char PYTHON_METAFUNCGRAPH_FLAG[] = "__metafuncgraph_flag__"; -const char PYTHON_TENSOR_FLAG[] = "__tensor_flag__"; -const char PYTHON_META_TENSOR_FLAG[] = "__meta_tensor_flag__"; -const char PYTHON_ENVINSTANCE_FLAG[] = "__envinstance_flag__"; -const char PYTHON_DTYPE_FLAG[] = "__dtype_flag__"; const char PYTHON_CELL_AS_LIST[] = "__cell_as_list__"; const char PYTHON_DATACLASS_FIELDS[] = "__dataclass_fields__"; const char PYTHON_CLASS_MEMBER_NAMESPACE[] = "__class_member_namespace__"; diff --git a/mindspore/ccsrc/pybind_api/export_flags.h b/mindspore/ccsrc/pybind_api/export_flags.h index a927794462..eb2348d88d 100644 --- a/mindspore/ccsrc/pybind_api/export_flags.h +++ b/mindspore/ccsrc/pybind_api/export_flags.h @@ -20,11 +20,6 @@ namespace mindspore { extern const char PYTHON_PRIMITIVE_FLAG[]; -extern const char PYTHON_METAFUNCGRAPH_FLAG[]; -extern const char PYTHON_TENSOR_FLAG[]; -extern const char PYTHON_META_TENSOR_FLAG[]; -extern const char PYTHON_ENVINSTANCE_FLAG[]; -extern const char PYTHON_DTYPE_FLAG[]; extern const char PYTHON_CELL_AS_LIST[]; extern const char PYTHON_DATACLASS_FIELDS[]; extern const char PYTHON_CLASS_MEMBER_NAMESPACE[]; diff --git a/mindspore/ccsrc/utils/convert_utils.cc b/mindspore/ccsrc/utils/convert_utils.cc index 140bcdcfb1..3e2b926e77 100644 --- a/mindspore/ccsrc/utils/convert_utils.cc +++ b/mindspore/ccsrc/utils/convert_utils.cc @@ -367,8 +367,7 @@ py::object VectorRefToPyData(const VectorRef &value_list) { } AbstractBasePtr PyListDtype2AbstractTensor(const py::object &shape_obj, const py::object &type_obj) { - if ((py::isinstance(shape_obj) || py::isinstance(shape_obj)) && - py::hasattr(type_obj, PYTHON_DTYPE_FLAG)) { + if ((py::isinstance(shape_obj) || py::isinstance(shape_obj)) && py::isinstance(type_obj)) { auto ret_vec = shape_obj.cast>(); auto ret_dtype = type_obj.cast(); MS_EXCEPTION_IF_NULL(ret_dtype); diff --git a/mindspore/ccsrc/utils/symbolic.h b/mindspore/ccsrc/utils/symbolic.h index ca68b2c877..9019000233 100644 --- a/mindspore/ccsrc/utils/symbolic.h +++ b/mindspore/ccsrc/utils/symbolic.h @@ -162,8 +162,6 @@ class EnvInstance : public Value { return Len(); } - const bool parse_info_ = true; - private: EnvInstanceContentsMap contents_; }; diff --git a/mindspore/core/ir/dtype/type.h b/mindspore/core/ir/dtype/type.h index 063f435bd5..77b3dc5079 100644 --- a/mindspore/core/ir/dtype/type.h +++ b/mindspore/core/ir/dtype/type.h @@ -84,8 +84,6 @@ class Type : public Value { friend std::ostream &operator<<(std::ostream &os, const Type &type); friend std::ostream &operator<<(std::ostream &os, const TypePtr type); - const bool parse_info_ = true; - private: TypeId meta_type_; bool is_generic_; diff --git a/mindspore/core/ir/dtype_py.cc b/mindspore/core/ir/dtype_py.cc index 7577a39f7a..db02cb3257 100644 --- a/mindspore/core/ir/dtype_py.cc +++ b/mindspore/core/ir/dtype_py.cc @@ -35,7 +35,6 @@ REGISTER_PYBIND_DEFINE( "dump_type", [](const TypePtr &t) { return t->type_id(); }, "dump type"); (void)m_sub.def("str_to_type", &StringToType, "string to typeptr"); (void)py::class_>(m_sub, "Type") - .def_readonly(PYTHON_DTYPE_FLAG, &mindspore::Type::parse_info_) .def("__eq__", [](const TypePtr &t1, const py::object &other) { if (!py::isinstance(other)) { diff --git a/mindspore/core/ir/func_graph_py.cc b/mindspore/core/ir/func_graph_py.cc index cff25b5aa1..f6bb419a10 100644 --- a/mindspore/core/ir/func_graph_py.cc +++ b/mindspore/core/ir/func_graph_py.cc @@ -24,7 +24,7 @@ namespace mindspore { REGISTER_PYBIND_DEFINE(FuncGraph, ([](const pybind11::module *m) { // Define python "MetaFuncGraph_" class (void)py::class_>(*m, "MetaFuncGraph_") - .def_readonly(PYTHON_METAFUNCGRAPH_FLAG, &MetaFuncGraph::parse_info_) + // .def_readonly(PYTHON_METAFUNCGRAPH_FLAG, &MetaFuncGraph::parse_info_) .def(py::init()); // Define python "FuncGraph" class (void)py::class_(*m, "FuncGraph") diff --git a/mindspore/core/ir/meta_func_graph.h b/mindspore/core/ir/meta_func_graph.h index d15c08feb0..3193c33926 100644 --- a/mindspore/core/ir/meta_func_graph.h +++ b/mindspore/core/ir/meta_func_graph.h @@ -72,7 +72,7 @@ class MetaFuncGraph : public FuncGraphBase { return false; } } - const bool parse_info_ = true; + // const bool parse_info_ = true; protected: template diff --git a/mindspore/core/ir/meta_tensor.h b/mindspore/core/ir/meta_tensor.h index abf877da29..22bd5ad290 100644 --- a/mindspore/core/ir/meta_tensor.h +++ b/mindspore/core/ir/meta_tensor.h @@ -163,7 +163,6 @@ class MetaTensor : public Value { return false; } } - const bool parse_info_ = true; protected: // brief Data type of the tensor. diff --git a/mindspore/core/ir/tensor.h b/mindspore/core/ir/tensor.h index ce319e7443..2f844b7171 100644 --- a/mindspore/core/ir/tensor.h +++ b/mindspore/core/ir/tensor.h @@ -224,8 +224,6 @@ class Tensor : public MetaTensor { std::string id() const { return id_; } - const bool parse_info_ = true; - private: bool init_flag_{false}; TensorDataPtr data_{nullptr}; diff --git a/mindspore/core/ir/tensor_py.cc b/mindspore/core/ir/tensor_py.cc index 88c8f219bf..b5b4fc0d69 100644 --- a/mindspore/core/ir/tensor_py.cc +++ b/mindspore/core/ir/tensor_py.cc @@ -214,7 +214,6 @@ REGISTER_PYBIND_DEFINE(Tensor, ([](const py::module *m) { // Define python MetaTensor class. (void)py::class_>(*m, "MetaTensor") .def(py::init>(), py::arg("dtype"), py::arg("shape")) - .def_readonly(PYTHON_META_TENSOR_FLAG, &MetaTensor::parse_info_) .def_property_readonly("dtype", &MetaTensor::Dtype, "Get the MetaTensor's dtype.") .def_property_readonly("shape", &MetaTensor::shape, "Get the MetaTensor's shape.") .def(py::pickle( @@ -268,7 +267,6 @@ REGISTER_PYBIND_DEFINE(Tensor, ([](const py::module *m) { return TensorPy::MakeTensor(py::array(input), type_ptr); }), py::arg("input"), py::arg("dtype") = nullptr) - .def_readonly(PYTHON_TENSOR_FLAG, &Tensor::parse_info_) .def_property("init_flag", &Tensor::is_init, &Tensor::set_init_flag) .def_property_readonly("dtype", &Tensor::Dtype, R"mydelimiter( Get the tensor's data type.