From: @tina_mengting_zhang Reviewed-by: @john_tzanakakis,@tom__chen Signed-off-by: @john_tzanakakispull/16033/MERGE
| @@ -79,12 +79,12 @@ class DebugServices { | |||
| RANGE | |||
| }; | |||
| typedef struct condition { | |||
| struct condition_t { | |||
| CONDITION_TYPE type; | |||
| float parameter = 0; | |||
| } condition_t; | |||
| }; | |||
| typedef struct parameter { | |||
| struct parameter_t { | |||
| std::string name; | |||
| bool disabled; | |||
| double_t value; | |||
| @@ -110,9 +110,9 @@ class DebugServices { | |||
| hit = condition_check[inequality_type]; | |||
| } | |||
| } parameter_t; | |||
| }; | |||
| typedef struct watchpoint { | |||
| struct watchpoint_t { | |||
| unsigned int id; | |||
| condition_t condition; | |||
| std::vector<std::tuple<std::string, bool>> check_node_list; | |||
| @@ -180,7 +180,7 @@ class DebugServices { | |||
| bool change_condition() const { | |||
| return condition.type == CHANGE_TOO_LARGE || condition.type == CHANGE_TOO_SMALL || condition.type == NOT_CHANGED; | |||
| } | |||
| } watchpoint_t; | |||
| }; | |||
| void AddWatchpoint( | |||
| unsigned int id, unsigned int watch_condition, float parameter, | |||
| @@ -30,8 +30,8 @@ | |||
| #include "debug/debug_services.h" | |||
| namespace py = pybind11; | |||
| typedef struct parameter { | |||
| parameter(const std::string &name, bool disabled, double value, bool hit, double actual_value) | |||
| struct parameter_t { | |||
| parameter_t(const std::string &name, bool disabled, double value, bool hit, double actual_value) | |||
| : name(name), disabled(disabled), value(value), hit(hit), actual_value(actual_value) {} | |||
| const std::string get_name() const { return name; } | |||
| const bool get_disabled() const { return disabled; } | |||
| @@ -43,12 +43,12 @@ typedef struct parameter { | |||
| double value; | |||
| bool hit; | |||
| double actual_value; | |||
| } parameter_t; | |||
| }; | |||
| typedef struct watchpoint_hit { | |||
| watchpoint_hit(const std::string &name, uint32_t slot, int condition, uint32_t watchpoint_id, | |||
| const std::vector<parameter_t> ¶meters, int32_t error_code, uint32_t device_id, | |||
| uint32_t root_graph_id) | |||
| struct watchpoint_hit_t { | |||
| watchpoint_hit_t(const std::string &name, uint32_t slot, int condition, uint32_t watchpoint_id, | |||
| const std::vector<parameter_t> ¶meters, int32_t error_code, uint32_t device_id, | |||
| uint32_t root_graph_id) | |||
| : name(name), | |||
| slot(slot), | |||
| condition(condition), | |||
| @@ -73,11 +73,11 @@ typedef struct watchpoint_hit { | |||
| int32_t error_code; | |||
| uint32_t device_id; | |||
| uint32_t root_graph_id; | |||
| } watchpoint_hit_t; | |||
| }; | |||
| typedef struct tensor_info { | |||
| tensor_info(const std::string &node_name, uint32_t slot, uint32_t iteration, uint32_t device_id, | |||
| uint32_t root_graph_id, bool is_parameter) | |||
| struct tensor_info_t { | |||
| tensor_info_t(const std::string &node_name, uint32_t slot, uint32_t iteration, uint32_t device_id, | |||
| uint32_t root_graph_id, bool is_parameter) | |||
| : node_name(node_name), | |||
| slot(slot), | |||
| iteration(iteration), | |||
| @@ -96,10 +96,10 @@ typedef struct tensor_info { | |||
| uint32_t device_id; | |||
| uint32_t root_graph_id; | |||
| bool is_parameter; | |||
| } tensor_info_t; | |||
| }; | |||
| typedef struct tensor_data { | |||
| tensor_data(char *data_ptr, uint64_t data_size, int dtype, const std::vector<int64_t> &shape) | |||
| struct tensor_data_t { | |||
| tensor_data_t(char *data_ptr, uint64_t data_size, int dtype, const std::vector<int64_t> &shape) | |||
| : data_size(data_size), dtype(dtype), shape(shape) { | |||
| if (data_ptr != NULL) { | |||
| this->data_ptr = py::bytes(data_ptr, data_size); | |||
| @@ -115,7 +115,7 @@ typedef struct tensor_data { | |||
| uint64_t data_size; | |||
| int dtype; | |||
| std::vector<int64_t> shape; | |||
| } tensor_data_t; | |||
| }; | |||
| class DbgServices { | |||
| private: | |||
| @@ -29,38 +29,38 @@ PYBIND11_MODULE(_mindspore_offline_debug, m) { | |||
| .def("ReadTensors", &DbgServices::ReadTensors) | |||
| .def("GetVersion", &DbgServices::GetVersion); | |||
| py::class_<parameter>(m, "parameter") | |||
| py::class_<parameter_t>(m, "parameter") | |||
| .def(py::init<std::string, bool, double, bool, double>()) | |||
| .def("get_name", ¶meter::get_name) | |||
| .def("get_disabled", ¶meter::get_disabled) | |||
| .def("get_value", ¶meter::get_value) | |||
| .def("get_hit", ¶meter::get_hit) | |||
| .def("get_actual_value", ¶meter::get_actual_value); | |||
| .def("get_name", ¶meter_t::get_name) | |||
| .def("get_disabled", ¶meter_t::get_disabled) | |||
| .def("get_value", ¶meter_t::get_value) | |||
| .def("get_hit", ¶meter_t::get_hit) | |||
| .def("get_actual_value", ¶meter_t::get_actual_value); | |||
| py::class_<watchpoint_hit>(m, "watchpoint_hit") | |||
| py::class_<watchpoint_hit_t>(m, "watchpoint_hit") | |||
| .def(py::init<std::string, uint32_t, int, uint32_t, std::vector<parameter_t>, int32_t, uint32_t, uint32_t>()) | |||
| .def("get_name", &watchpoint_hit::get_name) | |||
| .def("get_slot", &watchpoint_hit::get_slot) | |||
| .def("get_condition", &watchpoint_hit::get_condition) | |||
| .def("get_watchpoint_id", &watchpoint_hit::get_watchpoint_id) | |||
| .def("get_parameters", &watchpoint_hit::get_parameters) | |||
| .def("get_error_code", &watchpoint_hit::get_error_code) | |||
| .def("get_device_id", &watchpoint_hit::get_device_id) | |||
| .def("get_root_graph_id", &watchpoint_hit::get_root_graph_id); | |||
| .def("get_name", &watchpoint_hit_t::get_name) | |||
| .def("get_slot", &watchpoint_hit_t::get_slot) | |||
| .def("get_condition", &watchpoint_hit_t::get_condition) | |||
| .def("get_watchpoint_id", &watchpoint_hit_t::get_watchpoint_id) | |||
| .def("get_parameters", &watchpoint_hit_t::get_parameters) | |||
| .def("get_error_code", &watchpoint_hit_t::get_error_code) | |||
| .def("get_device_id", &watchpoint_hit_t::get_device_id) | |||
| .def("get_root_graph_id", &watchpoint_hit_t::get_root_graph_id); | |||
| py::class_<tensor_info>(m, "tensor_info") | |||
| py::class_<tensor_info_t>(m, "tensor_info") | |||
| .def(py::init<std::string, uint32_t, uint32_t, uint32_t, uint32_t, bool>()) | |||
| .def("get_node_name", &tensor_info::get_node_name) | |||
| .def("get_slot", &tensor_info::get_slot) | |||
| .def("get_iteration", &tensor_info::get_iteration) | |||
| .def("get_device_id", &tensor_info::get_device_id) | |||
| .def("get_root_graph_id", &tensor_info::get_root_graph_id) | |||
| .def("get_is_parameter", &tensor_info::get_is_parameter); | |||
| .def("get_node_name", &tensor_info_t::get_node_name) | |||
| .def("get_slot", &tensor_info_t::get_slot) | |||
| .def("get_iteration", &tensor_info_t::get_iteration) | |||
| .def("get_device_id", &tensor_info_t::get_device_id) | |||
| .def("get_root_graph_id", &tensor_info_t::get_root_graph_id) | |||
| .def("get_is_parameter", &tensor_info_t::get_is_parameter); | |||
| py::class_<tensor_data>(m, "tensor_data") | |||
| py::class_<tensor_data_t>(m, "tensor_data") | |||
| .def(py::init<char *, uint64_t, int, std::vector<int64_t>>()) | |||
| .def("get_data_ptr", &tensor_data::get_data_ptr) | |||
| .def("get_data_size", &tensor_data::get_data_size) | |||
| .def("get_dtype", &tensor_data::get_dtype) | |||
| .def("get_shape", &tensor_data::get_shape); | |||
| .def("get_data_ptr", &tensor_data_t::get_data_ptr) | |||
| .def("get_data_size", &tensor_data_t::get_data_size) | |||
| .def("get_dtype", &tensor_data_t::get_dtype) | |||
| .def("get_shape", &tensor_data_t::get_shape); | |||
| } | |||