本章节主要介绍如何使用saved_model2om.py工具将训练保存的SavedModel格式的模型重新构图,转换为基于NPU版本用于加载om模型的SavedModel模型,在部署TF Serving时使用转换后的SavedModel模型可以缩短编译时间从而提升TF Serving部署性能。
参数 |
参数说明 |
取值示例 |
---|---|---|
--input_path |
|
/home/HwHiAiUser/inputpath/model |
--output_path |
|
/home/HwHiAiUser/outputpath/model |
--input_shape |
|
input:16,224,224,3 |
--soc_version |
|
Ascendxxx |
--profiling |
|
1 |
--method_name |
|
/tensorflow/serving/predict |
--new_input_nodes |
|
embedding:DT_FLOAT:bert/embedding/word_embeddings:0;add:DT_INT:bert/embedding/add:0 |
--new_output_nodes |
|
loss:loss/Softmax:0 |
--output_type |
node1:0:FP16 |
|
--input_fp16_nodes |
node_name1;node_name2 |
python3 saved_model2om.py --input_path "/home/HwHiAiUser/inputpath/model" --output_path "/home/HwHiAiUser/outputpath/model" --input_shape "input:16,224,224,3" --soc_version "Ascendxxx"
--soc_version的取值可在服务器种执行npu-smi info命令进行查询,在查询到的“Name”前增加Ascend信息,例如“Name”对应取值为xxxyy,实际配置的<soc_version>值为Ascendxxxyy。
如果在转换的过程中需要进行子图或者算子调优,请执行以下命令。
python3 saved_model2om.py --input_path "/home/HwHiAiUser/inputpath/model" --output_path "/home/HwHiAiUser/outputpath/model" --input_shape "input:16,224,224,3" --profiling "1"