Skip to content

Commit b5239a5

Browse files
Qualcomm AI Engine Direct - Remove unused callable dataset branch (pytorch#21461)
### Summary - Drop Callable from the type hint and docstring, and remove the dead callable(dataset) branch in `_ptq_calibrate`. ### Test plan General CI
1 parent 454f979 commit b5239a5

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎backends/qualcomm/export_utils.py‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def build_executorch_binary(
503503
model: torch.nn.Module, # noqa: B006
504504
qnn_config: QnnConfig,
505505
file_name: str,
506-
dataset: List[torch.Tensor] | Callable[[torch.fx.GraphModule], None],
506+
dataset: List[Tuple[torch.Tensor, ...]],
507507
quant_dtype: Optional[QuantDtype] = None,
508508
custom_quantizer: Optional[QnnQuantizer] = None,
509509
metadata=None,
@@ -520,7 +520,7 @@ def build_executorch_binary(
520520
model (torch.nn.Module): The model to be converted into an ExecuTorch binary.
521521
qnn_config: (QnnConfig): A config class that saves qnn lowering and execution configuration.
522522
file_name (str): Name for the output binary file (.pte).
523-
dataset (List[torch.Tensor] | Callable): A dataset for quantization calibration.
523+
dataset (List[Tuple[torch.Tensor, ...]]): A dataset for quantization calibration.
524524
quant_dtype (QuantDtype, optional): Data type for quantization.
525525
custom_quantizer (Callable, optional): Custom quantizer.
526526
metadata (dict, optional): An optional dictionary that maps each method name to a constant value in eager mode.
@@ -961,9 +961,6 @@ def _ptq_calibrate(captured_model, quantizer, dataset):
961961
annotated_model = prepare_pt2e(captured_model, quantizer)
962962
print("Quantizing(PTQ) the model...")
963963
# calibration
964-
if callable(dataset):
965-
dataset(annotated_model)
966-
else:
967-
for data in dataset:
968-
annotated_model(*data)
964+
for data in dataset:
965+
annotated_model(*data)
969966
return annotated_model

0 commit comments

Comments
 (0)