预测时如何打印模型中每一步的耗时?
收藏
预测时如何打印模型中每一步的耗时?
旧鸱c_
已解决
2#
回复于2021-08
可以在设置config时使用config.enable_profile()统计预测时每个算子和数据搬运的耗时。对于推理api的使用,可以参考官网文档Python预测API介绍。示例代码: # 设置config: def set_config(args): config = Config(args.model_file, args.params_file) config.disable_gpu() # enable_profile()打开后会统计每一步耗时 config.enable_profile() config.switch_use_feed_fetch_ops(False) config.switch_specify_input_names(True) config.switch_ir_optim(False) return config
0
收藏
请登录后评论
可以在设置config时使用config.enable_profile()统计预测时每个算子和数据搬运的耗时。对于推理api的使用,可以参考官网文档Python预测API介绍。示例代码:
# 设置config:
def set_config(args):
config = Config(args.model_file, args.params_file)
config.disable_gpu()
# enable_profile()打开后会统计每一步耗时
config.enable_profile()
config.switch_use_feed_fetch_ops(False)
config.switch_specify_input_names(True)
config.switch_ir_optim(False)
return config