Analyzer for debug data from dump directories.
| 128 | |
| 129 | |
| 130 | class DebugAnalyzer(object): |
| 131 | """Analyzer for debug data from dump directories.""" |
| 132 | |
| 133 | _TIMESTAMP_COLUMN_HEAD = "t (ms)" |
| 134 | _DUMP_SIZE_COLUMN_HEAD = "Size (B)" |
| 135 | _OP_TYPE_COLUMN_HEAD = "Op type" |
| 136 | _TENSOR_NAME_COLUMN_HEAD = "Tensor name" |
| 137 | |
| 138 | # Op types to be omitted when generating descriptions of graph structure. |
| 139 | _GRAPH_STRUCT_OP_TYPE_BLACKLIST = ( |
| 140 | "_Send", "_Recv", "_HostSend", "_HostRecv", "_Retval") |
| 141 | |
| 142 | def __init__(self, debug_dump, config): |
| 143 | """DebugAnalyzer constructor. |
| 144 | |
| 145 | Args: |
| 146 | debug_dump: A DebugDumpDir object. |
| 147 | config: A `cli_config.CLIConfig` object that carries user-facing |
| 148 | configurations. |
| 149 | """ |
| 150 | |
| 151 | self._debug_dump = debug_dump |
| 152 | self._evaluator = evaluator.ExpressionEvaluator(self._debug_dump) |
| 153 | |
| 154 | # Initialize tensor filters state. |
| 155 | self._tensor_filters = {} |
| 156 | |
| 157 | self._build_argument_parsers(config) |
| 158 | config.set_callback("graph_recursion_depth", |
| 159 | self._build_argument_parsers) |
| 160 | |
| 161 | # TODO(cais): Implement list_nodes. |
| 162 | |
| 163 | def _build_argument_parsers(self, config): |
| 164 | """Build argument parsers for DebugAnalayzer. |
| 165 | |
| 166 | Args: |
| 167 | config: A `cli_config.CLIConfig` object. |
| 168 | |
| 169 | Returns: |
| 170 | A dict mapping command handler name to `ArgumentParser` instance. |
| 171 | """ |
| 172 | # Argument parsers for command handlers. |
| 173 | self._arg_parsers = {} |
| 174 | |
| 175 | # Parser for list_tensors. |
| 176 | ap = argparse.ArgumentParser( |
| 177 | description="List dumped intermediate tensors.", |
| 178 | usage=argparse.SUPPRESS) |
| 179 | ap.add_argument( |
| 180 | "-f", |
| 181 | "--tensor_filter", |
| 182 | dest="tensor_filter", |
| 183 | type=str, |
| 184 | default="", |
| 185 | help="List only Tensors passing the filter of the specified name") |
| 186 | ap.add_argument( |
| 187 | "-fenn", |
no outgoing calls
no test coverage detected