@@ -22,27 +22,27 @@ this:
22
22
\ /
23
23
\ /
24
24
—-------------------------------------------------------
25
- | Dynamo Export |
25
+ | Export |
26
26
—-------------------------------------------------------
27
27
|
28
28
FX Graph in ATen XNNPACKQuantizer,
29
29
| or X86InductorQuantizer,
30
30
| or <Other Backend Quantizer>
31
31
| /
32
32
—--------------------------------------------------------
33
- | prepare_pt2e |
33
+ | prepare_pt2e |
34
34
—--------------------------------------------------------
35
35
|
36
36
Calibrate/Train
37
37
|
38
38
—--------------------------------------------------------
39
- | convert_pt2e |
39
+ | convert_pt2e |
40
40
—--------------------------------------------------------
41
41
|
42
42
Reference Quantized Model
43
43
|
44
44
—--------------------------------------------------------
45
- | Lowering |
45
+ | Lowering |
46
46
—--------------------------------------------------------
47
47
|
48
48
Executorch, or Inductor, or <Other Backends>
@@ -189,8 +189,6 @@ and rename it to ``data/resnet18_pretrained_float.pth``.
189
189
import numpy as np
190
190
191
191
import torch
192
- from torch.ao.quantization import get_default_qconfig, QConfigMapping
193
- from torch.ao.quantization.quantize_fx import prepare_fx, convert_fx, fuse_fx
194
192
import torch.nn as nn
195
193
from torch.utils.data import DataLoader
196
194
@@ -358,7 +356,10 @@ Here is how you can use ``torch.export`` to export the model:
358
356
from torch._export import capture_pre_autograd_graph
359
357
360
358
example_inputs = (torch.rand(2 , 3 , 224 , 224 ),)
361
- exported_model, _ = capture_pre_autograd_graph(model_to_quantize, * example_inputs)
359
+ exported_model = capture_pre_autograd_graph(model_to_quantize, example_inputs)
360
+ # or capture with dynamic dimensions
361
+ # from torch._export import dynamic_dim
362
+ # exported_model = capture_pre_autograd_graph(model_to_quantize, example_inputs, constraints=[dynamic_dim(example_inputs[0], 0)])
362
363
363
364
364
365
``capture_pre_autograd_graph `` is a short term API, it will be updated to use the offical ``torch.export `` API when that is ready.
@@ -532,9 +533,9 @@ We'll show how to save and load the quantized model.
532
533
# Rerun all steps to get a quantized model
533
534
model_to_quantize = load_model(saved_model_dir + float_model_file).to(" cpu" )
534
535
model_to_quantize.eval()
535
- import torch._dynamo as torchdynamo
536
+ from torch._export import capture_pre_autograd_graph
536
537
537
- exported_model, _ = torchdynamo.export (model_to_quantize, * copy.deepcopy( example_inputs), aten_graph = True , tracing_mode = " symbolic " )
538
+ exported_model = capture_pre_autograd_graph (model_to_quantize, example_inputs)
538
539
from torch.ao.quantization.quantizer.xnnpack_quantizer import (
539
540
XNNPACKQuantizer,
540
541
get_symmetric_quantization_config,
0 commit comments