创建 OFA 剪枝器 - 3.5 简体中文

Vitis AI 用户指南 (UG1414)

Document ID
UG1414
Release Date
2023-09-28
Version
3.5 简体中文

剪枝器需要两个实参:

  • 要剪枝的模型
  • 模型推断所需的输入
import torch
from pytorch_nndct import OFAPruner

inputs = torch.randn([1, 3, 224, 224], dtype=torch.float32)
pruner = OFAPruner(model, inputs)
注释: 输入无需采用真实数据。您可使用随机生成的虚拟数据,只要其形状和类型与真实数据相同即可。