以 INT8 張量僅執行 MLA
| 欄位 | 值 |
|---|---|
| 類別 | PCIe 協同處理 |
| 難度 | 中級 |
| 預估閱讀時間 | 15 分鐘 |
| 標籤 | PCIe, MLA, INT8, quantization, tensor |
一支程式在主機上量化影像、執行僅 MLA 的路徑、反量化輸出頭,並在同一個佇列上與預設路徑進行比對。
操作指南
檢視僅 MLA 的合約
在啟用 mla_only 的情況下建構 Model。info() 現在會回報 INT8 的輸入與輸出,每個都帶有 quant.scale 與 quant.zero_point。參考模型只有一個輸入 images,是 INT8 [640, 640, 3] HWC 張量。
pcie_host/tutorials/027_run_mla_only_int8/run_mla_only_int8.cpp
pcie::ModelOptions options;
options.mla_only = true;
pcie::Model model(args.model, options, connection);
const pcie::ModelInfo info = model.info();
if (info.inputs.size() != 1) {
throw std::runtime_error("the reference model has exactly one input");
}
std::cout << "MLA-only contract:\n";
for (const auto& input : info.inputs) {
const pcie::QuantParams& quant = require_quant(input);
std::cout << " input " << input.name << " " << input.dtype << " "
<< shape_string(input.shape) << " scale=" << quant.scale
<< " zero_point=" << quant.zero_point << '\n';
}
for (const auto& output : info.outputs) {
const pcie::QuantParams& quant = require_quant(output);
std::cout << " output " << output.name << " " << output.dtype << " "
<< shape_string(output.shape) << " scale=" << quant.scale
<< " zero_point=" << quant.zero_point << '\n';
}