r"""serialize the computing graph of `output_vars` and get byte result. Args: output_vars: output variables which are the graph's end point. keep_var_name: level for keeping variable names: * 0: none of the names are kept * 1: (default)keep names of outp
(
output_vars: Union[Dict[str, VarNode], List[VarNode]],
*,
keep_var_name: int = 1,
keep_opr_name: bool = False,
keep_param_name: bool = False,
keep_opr_priority: bool = False,
no_change_graph: bool = False,
strip_info_file=None,
append_json=False,
metadata=None,
dump_format=None,
model_version: int = 2,
compat_older_version: str = None,
)
| 367 | |
| 368 | |
| 369 | def dump_graph( |
| 370 | output_vars: Union[Dict[str, VarNode], List[VarNode]], |
| 371 | *, |
| 372 | keep_var_name: int = 1, |
| 373 | keep_opr_name: bool = False, |
| 374 | keep_param_name: bool = False, |
| 375 | keep_opr_priority: bool = False, |
| 376 | no_change_graph: bool = False, |
| 377 | strip_info_file=None, |
| 378 | append_json=False, |
| 379 | metadata=None, |
| 380 | dump_format=None, |
| 381 | model_version: int = 2, |
| 382 | compat_older_version: str = None, |
| 383 | ) -> Tuple[bytes, CompGraphDumpResult]: |
| 384 | r"""serialize the computing graph of `output_vars` and get byte result. |
| 385 | |
| 386 | Args: |
| 387 | output_vars: output variables which are the graph's end point. |
| 388 | keep_var_name: level for keeping variable names: |
| 389 | |
| 390 | * 0: none of the names are kept |
| 391 | * 1: (default)keep names of output vars |
| 392 | * 2: keep names of all (output and internal) vars |
| 393 | |
| 394 | keep_opr_name: whether to keep operator names. |
| 395 | keep_param_name: whether to keep param names, so param values can be |
| 396 | easily manipulated after loading model |
| 397 | keep_opr_priority: whether to keep priority setting for operators |
| 398 | no_change_graph: whether to change the compute graph when dump, for |
| 399 | model compatibility, some operators will convert to its compatible |
| 400 | format in this version. |
| 401 | |
| 402 | * if set False, some operators maybe convert to other operator for |
| 403 | compatibility, all operators will ensure compatibility. |
| 404 | * if set True, no operator will change in the graph when dump. |
| 405 | |
| 406 | strip_info_file: a string for path or a file handler. if is not None, |
| 407 | then the dump information for code strip would be written to ``strip_info_file`` |
| 408 | append_json: will be check when `strip_info_file` is not None. if set |
| 409 | true, the information for code strip will be append to strip_info_file. |
| 410 | if set false, will rewrite strip_info_file |
| 411 | dump_format: using different dump formats. the open source MegEngine |
| 412 | defaults to the FBS_V2 format, there are two format FBS_V2 and FBS to choose, |
| 413 | internal MegEngine have an other choice of internal proprietary formats |
| 414 | model_version: the model version of "FBS_V2", begin with version 2, this |
| 415 | works only when dump format is "FBS_V2". |
| 416 | compat_older_version: the specified megbrain version which is less than 8.16 for model forward compatibility, only support "8.14" currently. Default: None. |
| 417 | |
| 418 | Note: |
| 419 | The underlying C++ API only accepts a var list. If a dict is given, |
| 420 | the vars would be renamed to the given names. |
| 421 | |
| 422 | Returns: |
| 423 | dump result as byte string, and an instance of namedtuple |
| 424 | :class:`CompGraphDumpResult`, whose fields are: |
| 425 | |
| 426 | * ``nr_opr`` number of operators dumped |