インスペクターは、ターゲット デバイスに基づいてニューラル ネットワーク内の演算子にデバイスを割り当て、vai_q_pytorch がハードウェアを考慮した量子化を実行できるようにします。
次に、example/resnet18_quant.py のサンプル コードを示します。
quantizer = torch_quantizer(quant_mode=quant_mode,
module=model,
input_args=(input),
device=device,
quant_config_file=config_file,
target=target)
example/resnet18_quant.py でハードウェアを考慮したキャリブレーションを実行するには、次のコマンド ラインを実行します。
python resnet18_quant.py --quant_mode calib --target DPUCAHX8L_ISA0_SP
ハードウェアを考慮した量子化後のモデル精度をテストするには、次のコマンド ラインを実行します。
python resnet18_quant.py --quant_mode test --target DPUCAHX8L_ISA0_SP
量子化されたモデルを運用するには、次のコマンド ラインを実行します。
python resnet18_quant.py --quant_mode test --target DPUCAHX8L_ISA0_SP --subset_len 1 --batch_size 1 --deploy