File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 44# LICENSE file in the root directory of this source tree.
55
66import torch
7+ from torch import nn
8+ from torchao .quantization .pt2e .quantize_pt2e import convert_pt2e , prepare_pt2e
79
810from executorch import exir
911from executorch .backends .nxp .backend .custom_delegation_options import (
2527 ExecutorchProgramManager ,
2628)
2729from executorch .extension .export_util .utils import export_to_edge
28- from torch import nn
29- from torchao .quantization .pt2e .quantize_pt2e import convert_pt2e , prepare_pt2e
3030
3131
3232def _quantize_model (model , calibration_inputs : list [tuple [torch .Tensor ]]):
@@ -70,6 +70,9 @@ def to_quantized_edge_program(
7070 else tuple (torch .ones (input_shape ) for input_shape in input_shapes )
7171 )
7272
73+ # Make sure the model is in the evaluation mode.
74+ model .eval ()
75+
7376 exir_program_aten = torch .export .export_for_training (
7477 model , example_input , strict = True
7578 )
@@ -126,5 +129,9 @@ def to_edge_program(
126129 if type (input_shapes ) is tuple
127130 else tuple (torch .ones (input_shape ) for input_shape in input_shapes )
128131 )
132+
133+ # Make sure the model is in the evaluation mode.
134+ model .eval ()
135+
129136 exir_program = torch .export .export (model , example_input )
130137 return exir .to_edge (exir_program )
You can’t perform that action at this time.
0 commit comments