17
17
18
18
from torchao .prototype .quantization .codebook_coreml import CodebookWeightOnlyConfig
19
19
from torchao .quantization import IntxWeightOnlyConfig , PerAxis , PerGroup , quantize_
20
-
20
+ from executorch . exir . backend . utils import format_delegated_graph
21
21
22
22
def is_fbcode ():
23
23
return not hasattr (torch .version , "git_version" )
@@ -173,7 +173,7 @@ def test_dequantize_codebook_linear(self):
173
173
CodebookWeightOnlyConfig (dtype = torch .uint2 , block_size = [- 1 , 16 ]),
174
174
)
175
175
ep = torch .export .export (model , example_inputs )
176
- print ( "ORIGINAL MODEL" , ep )
176
+ assert "torch.ops.quant.dequantize_codebook.default" in ep . graph_module . code
177
177
delegated_program = executorch .exir .to_edge_transform_and_lower (
178
178
ep ,
179
179
partitioner = [self ._coreml_partitioner ()],
@@ -184,8 +184,11 @@ def test_dequantize_codebook_linear(self):
184
184
"executorch_call_delegate" ,
185
185
"getitem" ,
186
186
], f"Got unexpected node target after delegation: { node .target .__name__ } "
187
+
188
+ print (format_delegated_graph (delegated_program .exported_program ().graph_module ))
189
+
190
+
187
191
et_prog = delegated_program .to_executorch ()
188
- print (et_prog .exported_program ())
189
192
self ._compare_outputs (et_prog , model , example_inputs )
190
193
191
194
def test_dequantize_codebook_embedding (self ):
@@ -196,6 +199,7 @@ def test_dequantize_codebook_embedding(self):
196
199
lambda m , fqn : isinstance (m , torch .nn .Embedding ),
197
200
)
198
201
ep = torch .export .export (model , example_inputs )
202
+ assert "torch.ops.quant.dequantize_codebook.default" in ep .graph_module .code
199
203
delegated_program = executorch .exir .to_edge_transform_and_lower (
200
204
ep ,
201
205
partitioner = [self ._coreml_partitioner ()],
@@ -207,16 +211,15 @@ def test_dequantize_codebook_embedding(self):
207
211
"getitem" ,
208
212
], f"Got unexpected node target after delegation: { node .target .__name__ } "
209
213
et_prog = delegated_program .to_executorch ()
210
- print (et_prog .exported_program ())
211
214
self ._compare_outputs (et_prog , model , example_inputs )
212
215
213
216
214
217
if __name__ == "__main__" :
215
218
test_runner = TestTorchOps ()
216
- test_runner .test_dequantize_affine_b4w_embedding ()
217
- test_runner .test_dequantize_affine_b4w_linear ()
218
- test_runner .test_dequantize_affine_c4w_embedding ()
219
- test_runner .test_dequantize_affine_c4w_linear ()
220
- test_runner .test_dequantize_affine_c8w_embedding_b4w_linear ()
219
+ # test_runner.test_dequantize_affine_b4w_embedding()
220
+ # test_runner.test_dequantize_affine_b4w_linear()
221
+ # test_runner.test_dequantize_affine_c4w_embedding()
222
+ # test_runner.test_dequantize_affine_c4w_linear()
223
+ # test_runner.test_dequantize_affine_c8w_embedding_b4w_linear()
221
224
test_runner .test_dequantize_codebook_linear ()
222
225
test_runner .test_dequantize_codebook_embedding ()
0 commit comments