Commit 8c6c30b2 authored by Tsahi Glik's avatar Tsahi Glik Committed by Facebook GitHub Bot
Browse files

Update tutorial for learnable QAT

Summary:
Pull Request resolved: https://github.com/facebookresearch/d2go/pull/134

Updating `all_steps_qat` example config to use learnable QAT method.

And add logic in `GeneralizedRCNNPatch.prepare_for_quant` to call the new `d2go.utils.qat_utils.get_qat_qconfig` to properly support QAT in D2 (https://github.com/facebookresearch/d2go/commit/7992f91324aee6ae59795063a007c6837e60cdb8)Go training workflow

Differential Revision: D32147216

fbshipit-source-id: 32831c6156bc5c0775196ad8edc890a5292d204f
parent 9c326bb3
...@@ -8,6 +8,7 @@ import torch ...@@ -8,6 +8,7 @@ import torch
import torch.nn as nn import torch.nn as nn
from caffe2.proto import caffe2_pb2 from caffe2.proto import caffe2_pb2
from d2go.export.api import PredictorExportConfig from d2go.export.api import PredictorExportConfig
from d2go.utils.qat_utils import get_qat_qconfig
from detectron2.export.caffe2_modeling import ( from detectron2.export.caffe2_modeling import (
META_ARCH_CAFFE2_EXPORT_TYPE_MAP, META_ARCH_CAFFE2_EXPORT_TYPE_MAP,
convert_batched_inputs_to_c2_format, convert_batched_inputs_to_c2_format,
...@@ -235,7 +236,9 @@ def default_rcnn_prepare_for_quant(self, cfg): ...@@ -235,7 +236,9 @@ def default_rcnn_prepare_for_quant(self, cfg):
model = self model = self
torch.backends.quantized.engine = cfg.QUANTIZATION.BACKEND torch.backends.quantized.engine = cfg.QUANTIZATION.BACKEND
model.qconfig = ( model.qconfig = (
torch.ao.quantization.get_default_qat_qconfig(cfg.QUANTIZATION.BACKEND) get_qat_qconfig(
cfg.QUANTIZATION.BACKEND, cfg.QUANTIZATION.QAT.FAKE_QUANT_METHOD
)
if model.training if model.training
else torch.ao.quantization.get_default_qconfig(cfg.QUANTIZATION.BACKEND) else torch.ao.quantization.get_default_qconfig(cfg.QUANTIZATION.BACKEND)
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment