Skip to content

Commit

Permalink
[quant][graphmode][fx] Test to make sure dequantize node are placed p…
Browse files Browse the repository at this point in the history
…roperly (pytorch#47332)

Summary: Pull Request resolved: pytorch#47332

Test Plan: Imported from OSS

Reviewed By: supriyar

Differential Revision: D24719736

fbshipit-source-id: 51b1f14b479edbc5d7f28d85920faf5fee8dd5ea
  • Loading branch information
jerryzh168 authored and facebook-github-bot committed Nov 4, 2020
1 parent bba5a31 commit f588ad6
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/quantization/test_quantize_fx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,30 @@ def forward(self, x):
# quantize, should run with no errors
quantized = convert_fx(prepared_copy)

def test_dequantize(self):
r""" Test to make sure dequantize node are placed before
non-quantizable node
"""
class M(torch.nn.Module):
def __init__(self):
super().__init__()
self.conv = torch.nn.Conv2d(1, 1, 1)
self.act = torch.nn.GELU()

def forward(self, x):
x = self.conv(x)
return self.act(x)

data = torch.rand(5, 1, 3, 3, dtype=torch.float)
for quant_type in self.static_quant_types:
node_list = [
ns.call_module(nnq.Conv2d),
ns.call_method("dequantize"),
ns.call_module(nn.GELU),
]
self.checkGraphModeFxOp(
M().eval(), (data,), quant_type, expected_node_list=node_list)

@skipIfNoFBGEMM
class TestQuantizeFxOps(QuantizationTestCase):
"""Unit tests for individual ops
Expand Down

0 comments on commit f588ad6

Please sign in to comment.