使用 TVMC 编译和优化模型

本文介绍了如何使用TVMC工具编译和优化ONNX模型。首先,详细展示了获取、编译ResNet-50 v2模型的过程,接着探讨了数据预处理和后处理的步骤。然后,通过安装依赖并使用gridsearch调优,生成了调优模型,并对比了调优前后模型的性能,结果显示调优后的模型运行速度提高了约1.29倍。
摘要由CSDN通过智能技术生成

TVMC 介绍

TVMC 是一个将 TVM 的一些特性比如自动调优,编译,分析和运行模型等通过命令行前端暴露出来的工具。
TVMC 是一个 Python 应用程序,是 TVM Python 包的一部分。
可以通过下面的命令来启动TVMC命令行驱动程序python -m tvm.driver.tvmc

运行 tvmc --help 可以看到它支持的命令选项:

usage: tvmc [--config CONFIG] [-v] [--version] [-h] {run,tune,compile} ...

TVM compiler driver

optional arguments:
  --config CONFIG     configuration json file
  -v, --verbose       increase verbosity
  --version           print the version and exit
  -h, --help          show this help message and exit.

commands:
  {run,tune,compile}
    run               run a compiled module
    tune              auto-tune a model
    compile           compile a model.

TVMC - TVM driver command-line interface

从上面可以看到目前 TVMC 支持三种命令:run,tune,compile。针对不同的命令,也可以查看相关的帮助信息,例如:

tvmc run --help
usage: tvmc run [-h] [--device {cpu,cuda,cl,metal,vulkan,rocm,micro}]
                [--fill-mode {zeros,ones,random}] [-i INPUTS] [-o OUTPUTS]
                [--print-time] [--print-top N] [--profile] [--end-to-end]
                [--repeat N] [--number N] [--rpc-key RPC_KEY]
                [--rpc-tracker RPC_TRACKER] [--list-options]
                PATH

positional arguments:
  PATH                  path to the compiled module file or to the project
                        directory if '--device micro' is selected.

optional arguments:
  -h, --help            show this help message and exit
  --device {cpu,cuda,cl,metal,vulkan,rocm,micro}
                        target device to run the compiled module. Defaults to
                        'cpu'
  --fill-mode {zeros,ones,random}
                        fill all input tensors with values. In case
                        --inputs/-i is provided, they will take precedence
                        over --fill-mode. Any remaining inputs will be filled
                        using the chosen fill mode. Defaults to 'random'
  -i INPUTS, --inputs INPUTS
                        path to the .npz input file
  -o OUTPUTS, --outputs OUTPUTS
                        path to th
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值