MCPcopy Create free account
hub / github.com/pytorch/executorch / get_exported_graph

Function get_exported_graph

backends/vulkan/test/utils.py:196–223  ·  view source on GitHub ↗
(
    model,
    sample_inputs,
    sample_kwargs=None,
    dynamic_shapes=None,
    qmode=QuantizationMode.NONE,
)

Source from the content-addressed store, hash-verified

194
195
196def get_exported_graph(
197 model,
198 sample_inputs,
199 sample_kwargs=None,
200 dynamic_shapes=None,
201 qmode=QuantizationMode.NONE,
202) -> torch.fx.GraphModule:
203 export_training_graph = export(
204 model,
205 sample_inputs,
206 kwargs=sample_kwargs,
207 dynamic_shapes=dynamic_shapes,
208 strict=True,
209 ).module()
210
211 if qmode == QuantizationMode.NONE:
212 return export_training_graph
213
214 quantizer = XNNPACKQuantizer()
215
216 operator_config = get_symmetric_quantization_config(is_per_channel=True)
217 quantizer.set_global(operator_config)
218
219 prepared_graph = prepare_pt2e(export_training_graph, quantizer)
220 prepared_graph(*sample_inputs)
221 converted_graph = convert_pt2e(prepared_graph)
222
223 return converted_graph
224
225
226def random_uniform_tensor(shape, low=0.0, high=1.0, device=None, dtype=None):

Callers 2

export_model_to_vulkanFunction · 0.70
export_model_to_xnnpackFunction · 0.70

Calls 5

set_globalMethod · 0.95
exportFunction · 0.90
XNNPACKQuantizerClass · 0.90
moduleMethod · 0.80

Tested by

no test coverage detected