【前言】
IPU Saved Model Tool是一款用于处理saved_model.pb模型的工具,用户可以借助此工具预览模型信息,转换模型,推理模型,以及对比CPU与IPU模型结果。本手册具体介绍工具的运行环境,模型操作,以及常见问题
【环境要求】
- 安装官方POPLAR SDK包,版本2.2.2 <=
- 包含Graphcore代码的Tensorflow1.15(arm/intel).whl(对应SDK文件下)
- python 3.6 <=
运行本工具如在没有IPU加速卡环境运行,应添加CPU仿真环境变量--use_ipu_model到TF_POPLAR_FLAGS
export TF_POPLAR_FLAGS=--max_compilation_threads=40 --use_ipu_model --show_progress_bar=true
【模型操作】
模型操作包括子命令show,convert,run,compare。 show命令主要用于查看模型signature信息, 输入输出tensor信息。convert命令主要用于对模型操作,包括IPU转换,子图切除,精度转换,pipeline加速等。run和compare命令用于模型推理以及对比结果
-
模型预览
使用ipu_saved_model_tool的show命令可以显示模型信息,示例如下:
python saved_model_cli.py show --dir=/model_path --all
展示内容示例:
MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:
signature_def['serving_default']: #模型对应signature-key
The given SavedModel SignatureDef contains the following input(s):
inputs['inputs'] tensor_info: #key对应的输入字典
dtype: DT_STRING
shape: (1)
name: TensorDict/batch:0
The given SavedModel SignatureDef contains the following output(s):
outputs['outputs'] tensor_info:#key对应的输出字典
dtype: DT_FLOAT
shape: (-1, 128)
name: text_encoder/l2_normalize:0
Method name is: tensorflow/serving/predict
其中得到的signatur