MCPcopy
hub / github.com/OpenPPL/ppq / export_ppq_graph

Function export_ppq_graph

ppq/api/interface.py:546–590  ·  view source on GitHub ↗

使用这个函数将 PPQ ir 保存到文件,同时导出 PPQ 的量化配置信息。 该函数可以将 PPQ ir 保存为不同格式的模型文件。 this func dumps ppq IR to file, and exports quantization setting information simultaneously. 详细的支持情况请参考: ppq.parser.__ini__.py for details please refer to ppq.parser.__ini__.py Args: graph (BaseGraph): 被

(
    graph: BaseGraph,
    platform: TargetPlatform,
    graph_save_to: str,
    config_save_to: str = None,
    copy_graph: bool = True,
    **kwargs)

Source from the content-addressed store, hash-verified

544
545
546def export_ppq_graph(
547 graph: BaseGraph,
548 platform: TargetPlatform,
549 graph_save_to: str,
550 config_save_to: str = None,
551 copy_graph: bool = True,
552 **kwargs) -> None:
553 """使用这个函数将 PPQ ir 保存到文件,同时导出 PPQ 的量化配置信息。 该函数可以将 PPQ ir 保存为不同格式的模型文件。 this
554 func dumps ppq IR to file, and exports quantization setting information
555 simultaneously.
556
557 详细的支持情况请参考: ppq.parser.__ini__.py
558 for details please refer to ppq.parser.__ini__.py
559
560 Args:
561 graph (BaseGraph): 被保存的 ir
562 the ppq IR graph
563
564 platform (TargetPlatform): 期望部署的目标平台
565 target backend platform
566
567 graph_save_to (str): 模型保存文件名,不要写后缀名,ppq 会自己加后缀
568 filename to save, do not add postfix to this
569
570 config_save_to (str): 量化配置信息保存文件名。
571 注意部分平台导出时会将量化配置信息直接写入模型,在这种情况下设置此参数无效
572 note that some of platforms requires to write quantization setting
573 directly into the model file, this parameter won't have effect at
574 this situation
575
576 copy_graph (bool): 导出图的时候是否需要把图复制一份
577 Whether to copy graph when export.
578 """
579 for save_path in [graph_save_to, config_save_to]:
580 if save_path is None: continue
581 if os.path.exists(save_path):
582 if os.path.isfile(save_path):
583 ppq_warning(f'File {save_path} is already existed, Exporter will overwrite it.')
584 if os.path.isdir(save_path):
585 raise FileExistsError(f'File {save_path} is already existed, and it is a directory, '
586 'Exporter can not create file here.')
587
588 exporter = PFL.Exporter(platform)
589 if copy_graph: graph = graph.copy()
590 exporter.export(file_path=graph_save_to, config_path=config_save_to, graph=graph, **kwargs)
591
592
593def format_graph(graph: BaseGraph) -> BaseGraph:

Callers 15

quantize_dsp.pyFile · 0.90
yolo_5.pyFile · 0.90
targetPlatform.pyFile · 0.90
quantize.pyFile · 0.90
Example_PTQ.pyFile · 0.90
test_graph_api.pyFile · 0.90

Calls 3

ppq_warningFunction · 0.90
copyMethod · 0.45
exportMethod · 0.45

Tested by

no test coverage detected