Skip to content

Commit

Permalink
Clean up some type annotations in caffe2/torch/quantization (#49942)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #49942

Upgrades type annotations from Python2 to Python3

Test Plan: Sandcastle tests

Reviewed By: vkuzo

Differential Revision: D25717551

fbshipit-source-id: d52555d701793b7c07e561df56acd82c966bdb7c
  • Loading branch information
r-barnes authored and facebook-github-bot committed Dec 29, 2020
1 parent a111a92 commit c26830e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
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

0 comments on commit c26830e

Please sign in to comment.