Browse Source

delete tensor history in retrieve_node_by_bfs method

tags/v1.0.0
yelihua 5 years ago
parent
commit
7cdcfafc91
4 changed files with 17 additions and 8 deletions
  1. +11
    -3
      mindinsight/debugger/debugger_server.py
  2. +1
    -0
      mindinsight/debugger/stream_cache/tensor.py
  3. +3
    -4
      mindinsight/debugger/stream_handler/graph_handler.py
  4. +2
    -1
      mindinsight/debugger/stream_handler/tensor_handler.py

+ 11
- 3
mindinsight/debugger/debugger_server.py View File

@@ -713,7 +713,17 @@ class DebuggerServer:
return {'metadata': {'state': 'pending'}}

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",
node_name, ascend)
reply = {}
@@ -728,9 +738,7 @@ class DebuggerServer:
'single_node': True
}
search_graph = self._get_nodes_info(filter_condition)
tensor_history = self._get_tensor_history(next_node_name)
reply = {'name': next_node_name}
reply.update(search_graph)
reply.update(tensor_history)

return reply

+ 1
- 0
mindinsight/debugger/stream_cache/tensor.py View File

@@ -148,6 +148,7 @@ class OpTensor(BaseTensor):
"""
tensor_value = self.get_tensor_value_by_shape(shape)
res = {}
# the type of tensor_value is one of None, np.ndarray or str
if isinstance(tensor_value, np.ndarray):
statistics = TensorUtils.get_statistics_from_tensor(tensor_value)
res['statistics'] = TensorUtils.get_statistics_dict(statistics)


+ 3
- 4
mindinsight/debugger/stream_handler/graph_handler.py View File

@@ -229,13 +229,12 @@ class GraphHandler(StreamHandlerBase):
Traverse the graph in order of breath-first search by given node.

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;
If False, traverse the output nodes. Default is True.

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()
bfs_order = self.bfs_order
@@ -248,7 +247,7 @@ class GraphHandler(StreamHandlerBase):

if node_name is None:
if ascend is False:
next_node = bfs_order[-1]
next_node = None
else:
next_node = bfs_order[0]
else:


+ 2
- 1
mindinsight/debugger/stream_handler/tensor_handler.py View File

@@ -224,7 +224,7 @@ class TensorHandler(StreamHandlerBase):
if prev_step < 0:
return flag
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):
"""Get tensor value by name in numpy type."""
@@ -283,6 +283,7 @@ class TensorHandler(StreamHandlerBase):
if isinstance(tensor_info, dict):
del tensor_info['has_prev_step']
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):
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)


Loading…
Cancel
Save