Skip to content

Commit 79bdfac

Browse files
Karthik Prasadfacebook-github-bot
authored andcommitted
Type check lint fixes (#599)
Summary: ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Docs change / refactoring / dependency upgrade ## Motivation and Context / Related issue Fixing flake8 lint issue detected in https://app.circleci.com/pipelines/github/pytorch/opacus/2835/workflows/1318787a-42c8-42a2-aba5-85e32eac7d2a/jobs/16079 ## How Has This Been Tested (if it applies) CI ## Checklist - [x] The documentation is up-to-date with the changes I made. - [x] I have read the **CONTRIBUTING** document and completed the CLA (see **CONTRIBUTING**). - [x] All tests passed, and additional code has been covered with new tests. Pull Request resolved: #599 Reviewed By: JohnlNguyen Differential Revision: D47936830 Pulled By: karthikprasad fbshipit-source-id: 800f18ebfaf10ff65e9ceb2a0dbb9f182efee759
1 parent 7b28054 commit 79bdfac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

opacus/grad_sample/conv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ def compute_conv_grad_sample(
5151
return ret
5252

5353
# get activations and backprops in shape depending on the Conv layer
54-
if type(layer) == nn.Conv2d:
54+
if type(layer) is nn.Conv2d:
5555
activations = unfold2d(
5656
activations,
5757
kernel_size=layer.kernel_size,
5858
padding=layer.padding,
5959
stride=layer.stride,
6060
dilation=layer.dilation,
6161
)
62-
elif type(layer) == nn.Conv1d:
62+
elif type(layer) is nn.Conv1d:
6363
activations = activations.unsqueeze(-2) # add the H dimension
6464
# set arguments to tuples with appropriate second element
6565
if layer.padding == "same":
@@ -77,7 +77,7 @@ def compute_conv_grad_sample(
7777
stride=(1, layer.stride[0]),
7878
dilation=(1, layer.dilation[0]),
7979
)
80-
elif type(layer) == nn.Conv3d:
80+
elif type(layer) is nn.Conv3d:
8181
activations = unfold3d(
8282
activations,
8383
kernel_size=layer.kernel_size,

opacus/privacy_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _prepare_model(
181181
if (
182182
module.batch_first != batch_first
183183
or module.loss_reduction != loss_reduction
184-
or type(module) != get_gsm_class(grad_sample_mode)
184+
or type(module) is not get_gsm_class(grad_sample_mode)
185185
):
186186
raise ValueError(
187187
f"Pre-existing GradSampleModule doesn't match new arguments."

0 commit comments

Comments
 (0)