Skip to content

Commit 537fdd7

Browse files
jerryzh168facebook-github-bot
authored andcommitted
[quant][graphmode] quantization support for view, transpose, contiguos (#34854)
Summary: Pull Request resolved: #34854 Test Plan: python test/test_jit.py Imported from OSS Differential Revision: D20524456 fbshipit-source-id: e6e8fc3db6cccbd32c210d04f921274d81996fe2
1 parent 4a96911 commit 537fdd7

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

test/test_jit.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,9 @@ def forward(self, x):
21552155
x = torch.min(x)
21562156
x = torch.mean(x)
21572157
x = x.reshape([-1])
2158+
x = x.view(-1)
2159+
x = x.transpose(1, 2)
2160+
x = x.contiguous()
21582161
x, y = torch.chunk(x, 2)
21592162
x = F.dropout(x)
21602163
x = self.dropout(x)
@@ -2178,6 +2181,9 @@ def forward(self, x):
21782181
.check("aten::min") \
21792182
.check("aten::mean") \
21802183
.check("aten::reshape") \
2184+
.check("aten::view") \
2185+
.check("aten::transpose") \
2186+
.check("aten::contiguous") \
21812187
.check("aten::chunk") \
21822188
.check("prim::ListUnpack") \
21832189
.check("aten::dropout") \
@@ -2192,6 +2198,9 @@ def forward(self, x):
21922198
.check("aten::min") \
21932199
.check("aten::mean") \
21942200
.check("aten::reshape") \
2201+
.check("aten::view") \
2202+
.check("aten::transpose") \
2203+
.check("aten::contiguous") \
21952204
.check("aten::chunk") \
21962205
.check("prim::ListUnpack") \
21972206
.check("aten::dropout") \

torch/csrc/jit/passes/quantization.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ std::vector<size_t> getGeneralOpTensorInputIndexes(Node* n) {
137137
"dropout",
138138
"reshape",
139139
"chunk",
140+
"view",
141+
"transpose",
142+
"contiguous",
140143
// TODO: sort returns a tuple of Tensors, we have
141144
// to extend the API to support that
142145
// "sort",

0 commit comments

Comments
 (0)