Skip to content

Commit ad7fb23

Browse files
committed
NXP backend: Disable training mode for converted models.
1 parent 1520f9f commit ad7fb23

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

backends/nxp/tests/executorch_pipeline.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
# LICENSE file in the root directory of this source tree.
55

66
import torch
7+
from torch import nn
8+
from torchao.quantization.pt2e.quantize_pt2e import convert_pt2e, prepare_pt2e
79

810
from executorch import exir
911
from executorch.backends.nxp.backend.custom_delegation_options import (
@@ -25,8 +27,6 @@
2527
ExecutorchProgramManager,
2628
)
2729
from 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

3232
def _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)

0 commit comments

Comments
 (0)