Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up some type annotations in caffe2/torch/quantization #49942

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion torch/quantization/_numeric_suite_fx.py
Expand Up @@ -21,7 +21,7 @@
def remove_qconfig_observer_fx(model):
# remove activation post process
act_post_process_removed_graph = Graph()
env = {} # type: Dict[str, Any]
env: Dict[str, Any] = {}

modules = dict(model.named_modules())

Expand Down
6 changes: 2 additions & 4 deletions torch/quantization/fake_quantize.py
Expand Up @@ -41,17 +41,15 @@ def calculate_qparams(self, **kwargs):
pass

@torch.jit.export
def enable_fake_quant(self, enabled=True):
# type: (bool) -> None
def enable_fake_quant(self, enabled: bool = True) -> None:
self.fake_quant_enabled[0] = 1 if enabled else 0

@torch.jit.export
def disable_fake_quant(self):
self.enable_fake_quant(False)

@torch.jit.export
def enable_observer(self, enabled=True):
# type: (bool) -> None
def enable_observer(self, enabled: bool = True) -> None:
self.observer_enabled[0] = 1 if enabled else 0

@torch.jit.export
Expand Down
3 changes: 1 addition & 2 deletions torch/quantization/observer.py
Expand Up @@ -877,8 +877,7 @@ def _combine_histograms(self,
orig_hist = orig_hist + interpolated_histogram.to(torch.float)
return orig_hist

def forward(self, x_orig):
# type: (torch.Tensor) -> torch.Tensor
def forward(self, x_orig: torch.Tensor) -> torch.Tensor:
x = x_orig.detach()
min_val = self.min_val
max_val = self.max_val
Expand Down