Skip to content

Commit 6219be2

Browse files
Arm backend: Make quantize_with_submodules private
Change-Id: If9d3aade49e92f45af4266d14e0bcc149c371a21 Signed-off-by: Sebastian Larsson <sebastian.larsson@arm.com>
1 parent 512b4e0 commit 6219be2

File tree

4 files changed

+3
-49
lines changed

4 files changed

+3
-49
lines changed

backends/arm/quantizer/arm_quantizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ def validate(self, model: GraphModule) -> None:
754754
f"Quantizer detected operator {node.name} with different device inputs: {devices}."
755755
)
756756

757-
def quantize_with_submodules(
757+
def _quantize_with_submodules(
758758
self,
759759
model: GraphModule,
760760
calibration_samples: list[tuple],

backends/arm/test/tester/quantize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def run(
5050
raise ValueError("ArmQuantizer can only run with TOSAQuantizer.")
5151

5252
if self.calibration_samples is not None:
53-
converted = self.quantizer.quantize_with_submodules(
53+
converted = self.quantizer._quantize_with_submodules(
5454
captured_graph, self.calibration_samples, bool(self.is_qat), self.fold_quantize # type: ignore
5555
)
5656
else:
57-
converted = self.quantizer.quantize_with_submodules(
57+
converted = self.quantizer._quantize_with_submodules(
5858
captured_graph, [inputs], bool(self.is_qat), self.fold_quantize
5959
)
6060

docs/source/backends/arm-ethos-u/arm-ethos-u-quantization.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,6 @@ def EthosUQuantizer.add_quantizer(self, quantizer: 'Quantizer') -> 'TOSAQuantize
3434
```
3535
Insert a quantizer with highest precedence.
3636

37-
```python
38-
def EthosUQuantizer.quantize_with_submodules(self, model: 'GraphModule', calibration_samples: 'list[tuple]', is_qat: 'bool' = False, fold_quantize: 'bool' = True):
39-
```
40-
Quantizes a GraphModule in a way such that conditional submodules are
41-
handled properly.
42-
43-
Note: torchao's prepare_pt2e and convert_pt2e natively handle
44-
while_loop body_fn submodules, so we only manually process cond
45-
branches and while_loop cond_fn here.
46-
47-
Args:
48-
- **model (GraphModule)**: The model to quantize.
49-
- **calibration_samples (list[tuple])**: A list of inputs to used to
50-
calibrate the model during quantization. To properly calibrate a
51-
model with submodules, at least one sample per code path is
52-
needed.
53-
- **is_qat (bool)**: Whether to do quantization aware training or not.
54-
- **fold_quantize (bool)**: Enables or disables constant folding when quantization
55-
is completed.
56-
57-
Returns:
58-
- **GraphModule**: The quantized model.
59-
6037
```python
6138
def EthosUQuantizer.set_global(self, quantization_config: 'Optional[QuantizationConfig]') -> 'TOSAQuantizer':
6239
```

docs/source/backends/arm-vgf/arm-vgf-quantization.md

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -53,29 +53,6 @@ def VgfQuantizer.add_quantizer(self, quantizer: 'Quantizer') -> 'TOSAQuantizer':
5353
```
5454
Insert a quantizer with highest precedence.
5555

56-
```python
57-
def VgfQuantizer.quantize_with_submodules(self, model: 'GraphModule', calibration_samples: 'list[tuple]', is_qat: 'bool' = False, fold_quantize: 'bool' = True):
58-
```
59-
Quantizes a GraphModule in a way such that conditional submodules are
60-
handled properly.
61-
62-
Note: torchao's prepare_pt2e and convert_pt2e natively handle
63-
while_loop body_fn submodules, so we only manually process cond
64-
branches and while_loop cond_fn here.
65-
66-
Args:
67-
- **model (GraphModule)**: The model to quantize.
68-
- **calibration_samples (list[tuple])**: A list of inputs to used to
69-
calibrate the model during quantization. To properly calibrate a
70-
model with submodules, at least one sample per code path is
71-
needed.
72-
- **is_qat (bool)**: Whether to do quantization aware training or not.
73-
- **fold_quantize (bool)**: Enables or disables constant folding when quantization
74-
is completed.
75-
76-
Returns:
77-
- **GraphModule**: The quantized model.
78-
7956
```python
8057
def VgfQuantizer.set_global(self, quantization_config: 'Optional[QuantizationConfig]') -> 'TOSAQuantizer':
8158
```

0 commit comments

Comments
 (0)