評價此頁

QuantWrapper#

class torch.ao.quantization.QuantWrapper(module)[source]#

一個包裝輸入模組的包裝器類,新增 QuantStub 和 DeQuantStub,並將對模組的呼叫用對量化和反量化模組的呼叫包圍起來。

這由 `quantization` 實用函式使用,用於在 `convert` 函式之前新增量化和反量化模組。`QuantStub` 最初是一個觀察器,它觀察輸入張量;在 `convert` 之後,`QuantStub` 將被替換為 `nnq.Quantize`,後者執行實際的量化。DeQuantStub 也是類似的。