原始网络模型shape中存在不固定的维度值,模型转换未设置shape信息
2023/09/12
371
问题信息
问题来源 | 产品大类 | 产品子类 | 关键字 |
---|---|---|---|
官方 | 模型推理 | 模型转换 | ATC、模型转换、动态BatchSize、shape范围、shape分档 |
问题现象描述
获取原始网络模型,执行模型转换命令进行模型转换时,提示E10001报错信息。
atc --model=./resnet_shape.pb --framework=3 --output=./out/resnet_shape --soc_version=Ascend310
报错信息如下:
ATC run failed, Please check the detail log, Try 'atc --help' for more information E10001: Value [-1] for parameter [Inputs] is invalid. Reason: maybe you should set input_shape to specify its shape Solution: Try again with a valid argument.
原因分析
原始模型的shape存在不固定的维度值“-1”,模型输入样例如下,模型转换时,并未给不固定的维度值赋值。
解决措施
- 设置固定shape。
atc --model=./resnet_shape.pb --framework=3 --output=./out/resnet_shape --soc_version=Ascend310 --input_shape="Inputs:1,224,224,3"
- 设置shape分档。
与动态BatchSize参数配合使用,使转换后的模型进行推理时,可以每次处理多种数量的图片,示例如下:
atc --model=./resnet_shape.pb --framework=3 --output=./out/resnet_shape --soc_version=Ascend310 --input_shape="Inputs:-1,224,224,3" --dynamic_batch_size="1,2,4,8"
这样转换后的离线模型,可以支持每次处理1、2、4、8张图片,而不用再进行4次模型转换。
- 设置shape范围。
atc --model=./resnet_shape.pb --framework=3 --output=./out/resnet_shape --soc_version=Ascend910 --input_shape="Inputs:1~10,224,224,3"
这样转换后的离线模型,可以支持每次处理1~10张范围内的图片。
本页内容