| @@ -713,7 +713,17 @@ class DebuggerServer: | |||||
| return {'metadata': {'state': 'pending'}} | return {'metadata': {'state': 'pending'}} | ||||
| def retrieve_node_by_bfs(self, node_name, ascend=False): | def retrieve_node_by_bfs(self, node_name, ascend=False): | ||||
| """Get the graph and tensor history of the next node name according to node_name.""" | |||||
| """ | |||||
| Get the graph of the next node according to node_name. | |||||
| Args: | |||||
| node_name (str): The name of current chosen leaf node. | |||||
| ascend (bool): If True, traverse the input nodes; | |||||
| If False, traverse the output nodes. Default is True. | |||||
| Returns: | |||||
| dict, the next node information. | |||||
| """ | |||||
| log.info("Retrieve node <%s> by bfs, `ascend` is :%s", | log.info("Retrieve node <%s> by bfs, `ascend` is :%s", | ||||
| node_name, ascend) | node_name, ascend) | ||||
| reply = {} | reply = {} | ||||
| @@ -728,9 +738,7 @@ class DebuggerServer: | |||||
| 'single_node': True | 'single_node': True | ||||
| } | } | ||||
| search_graph = self._get_nodes_info(filter_condition) | search_graph = self._get_nodes_info(filter_condition) | ||||
| tensor_history = self._get_tensor_history(next_node_name) | |||||
| reply = {'name': next_node_name} | reply = {'name': next_node_name} | ||||
| reply.update(search_graph) | reply.update(search_graph) | ||||
| reply.update(tensor_history) | |||||
| return reply | return reply | ||||
| @@ -148,6 +148,7 @@ class OpTensor(BaseTensor): | |||||
| """ | """ | ||||
| tensor_value = self.get_tensor_value_by_shape(shape) | tensor_value = self.get_tensor_value_by_shape(shape) | ||||
| res = {} | res = {} | ||||
| # the type of tensor_value is one of None, np.ndarray or str | |||||
| if isinstance(tensor_value, np.ndarray): | if isinstance(tensor_value, np.ndarray): | ||||
| statistics = TensorUtils.get_statistics_from_tensor(tensor_value) | statistics = TensorUtils.get_statistics_from_tensor(tensor_value) | ||||
| res['statistics'] = TensorUtils.get_statistics_dict(statistics) | res['statistics'] = TensorUtils.get_statistics_dict(statistics) | ||||
| @@ -229,13 +229,12 @@ class GraphHandler(StreamHandlerBase): | |||||
| Traverse the graph in order of breath-first search by given node. | Traverse the graph in order of breath-first search by given node. | ||||
| Args: | Args: | ||||
| node_name (str): The node name which will be regarded | |||||
| as the start node in graph. | |||||
| node_name (str): The name of current chosen leaf node. | |||||
| ascend (bool): If True, traverse the input nodes; | ascend (bool): If True, traverse the input nodes; | ||||
| If False, traverse the output nodes. Default is True. | If False, traverse the output nodes. Default is True. | ||||
| Returns: | Returns: | ||||
| dict, including the searched node and its tensor value. | |||||
| Union[None, dict], the next node object in dict type or None. | |||||
| """ | """ | ||||
| self._graph_exists() | self._graph_exists() | ||||
| bfs_order = self.bfs_order | bfs_order = self.bfs_order | ||||
| @@ -248,7 +247,7 @@ class GraphHandler(StreamHandlerBase): | |||||
| if node_name is None: | if node_name is None: | ||||
| if ascend is False: | if ascend is False: | ||||
| next_node = bfs_order[-1] | |||||
| next_node = None | |||||
| else: | else: | ||||
| next_node = bfs_order[0] | next_node = bfs_order[0] | ||||
| else: | else: | ||||
| @@ -224,7 +224,7 @@ class TensorHandler(StreamHandlerBase): | |||||
| if prev_step < 0: | if prev_step < 0: | ||||
| return flag | return flag | ||||
| tensor = self._get_tensor(tensor_name, step=prev_step) | tensor = self._get_tensor(tensor_name, step=prev_step) | ||||
| return bool(tensor and tensor.valule) | |||||
| return bool(tensor and tensor.value) | |||||
| def get_tensor_value_by_name(self, tensor_name, prev=False): | def get_tensor_value_by_name(self, tensor_name, prev=False): | ||||
| """Get tensor value by name in numpy type.""" | """Get tensor value by name in numpy type.""" | ||||
| @@ -283,6 +283,7 @@ class TensorHandler(StreamHandlerBase): | |||||
| if isinstance(tensor_info, dict): | if isinstance(tensor_info, dict): | ||||
| del tensor_info['has_prev_step'] | del tensor_info['has_prev_step'] | ||||
| del tensor_info['value'] | del tensor_info['value'] | ||||
| # the type of curr_tensor_slice is one of None, np.ndarray or str | |||||
| if isinstance(curr_tensor_slice, np.ndarray) and isinstance(prev_tensor_slice, np.ndarray): | if isinstance(curr_tensor_slice, np.ndarray) and isinstance(prev_tensor_slice, np.ndarray): | ||||
| diff_tensor = TensorUtils.calc_diff_between_two_tensor(curr_tensor_slice, prev_tensor_slice, tolerance) | diff_tensor = TensorUtils.calc_diff_between_two_tensor(curr_tensor_slice, prev_tensor_slice, tolerance) | ||||
| result = np.stack([prev_tensor_slice, curr_tensor_slice, diff_tensor], axis=-1) | result = np.stack([prev_tensor_slice, curr_tensor_slice, diff_tensor], axis=-1) | ||||