(
model,
sample_inputs,
sample_kwargs=None,
dynamic_shapes=None,
operator_blocklist=None,
operator_allowlist=None,
nn_module_blocklist=None,
nn_module_allowlist=None,
qmode=QuantizationMode.NONE,
)
| 319 | |
| 320 | |
| 321 | def export_model_to_vulkan( |
| 322 | model, |
| 323 | sample_inputs, |
| 324 | sample_kwargs=None, |
| 325 | dynamic_shapes=None, |
| 326 | operator_blocklist=None, |
| 327 | operator_allowlist=None, |
| 328 | nn_module_blocklist=None, |
| 329 | nn_module_allowlist=None, |
| 330 | qmode=QuantizationMode.NONE, |
| 331 | ): |
| 332 | compile_options = {} |
| 333 | exported_graph = get_exported_graph( |
| 334 | model, |
| 335 | sample_inputs, |
| 336 | sample_kwargs=sample_kwargs, |
| 337 | dynamic_shapes=dynamic_shapes, |
| 338 | qmode=qmode, |
| 339 | ) |
| 340 | program = export( |
| 341 | exported_graph, |
| 342 | sample_inputs, |
| 343 | kwargs=sample_kwargs, |
| 344 | dynamic_shapes=dynamic_shapes, |
| 345 | strict=True, |
| 346 | ) |
| 347 | |
| 348 | edge_program = to_edge_transform_and_lower( |
| 349 | program, |
| 350 | partitioner=[ |
| 351 | VulkanPartitioner( |
| 352 | compile_options, |
| 353 | operator_blocklist=operator_blocklist, |
| 354 | operator_allowlist=operator_allowlist, |
| 355 | nn_module_blocklist=nn_module_blocklist, |
| 356 | nn_module_allowlist=nn_module_allowlist, |
| 357 | ) |
| 358 | ], |
| 359 | transform_passes=None, |
| 360 | compile_config=None, |
| 361 | ) |
| 362 | |
| 363 | executorch_program = edge_program.to_executorch() |
| 364 | |
| 365 | # Check if the delegate ID matches VulkanBackend |
| 366 | if ( |
| 367 | executorch_program.executorch_program.execution_plan[0].delegates[0].id |
| 368 | != VulkanBackend.__name__ |
| 369 | ): |
| 370 | raise RuntimeError( |
| 371 | f"Expected delegate ID {VulkanBackend.__name__}, but got {executorch_program.executorch_program.execution_plan[0].delegates[0].id}" |
| 372 | ) |
| 373 | |
| 374 | return executorch_program |
| 375 | |
| 376 | |
| 377 | def export_model_to_xnnpack( |
no test coverage detected