@@ -490,21 +490,17 @@ def _export_llama(modelname, args) -> str: # noqa: C901
490
490
).export_to_edge (quantizers )
491
491
492
492
# to_backend
493
- partitioners = {}
493
+ partitioner = None
494
494
if pt2e_quant_params is not None and pt2e_quant_params .quantize_linear is not None :
495
- partitioners [XnnpackDynamicallyQuantizedPartitioner .__name__ ] = (
496
- XnnpackDynamicallyQuantizedPartitioner ()
497
- )
495
+ partitioner = XnnpackDynamicallyQuantizedPartitioner ()
498
496
modelname = f"xnnpack_dq_{ modelname } "
499
497
500
498
if args .xnnpack :
501
499
# Following changes due to.
502
500
# 1. We need dynamically quantized partitioner for both pt2e_quantize options
503
501
# as well as "qmode int4" which is also dynamic quantizes linear layers.
504
502
# 2. XNNPACK partitioner seems to result in seg fault for non dqlinear ops.
505
- partitioners [XnnpackDynamicallyQuantizedPartitioner .__name__ ] = (
506
- XnnpackDynamicallyQuantizedPartitioner ()
507
- )
503
+ partitioner = XnnpackDynamicallyQuantizedPartitioner ()
508
504
# partitioners[XnnpackPartitioner.__name__] = XnnpackPartitioner()
509
505
modelname = f"xnnpack_{ modelname } "
510
506
@@ -516,7 +512,7 @@ def _export_llama(modelname, args) -> str: # noqa: C901
516
512
args .quantization_mode is None
517
513
), "Vulkan backend does not support quantization at the moment"
518
514
519
- partitioners [ VulkanPartitioner . __name__ ] = VulkanPartitioner ()
515
+ partitioner = VulkanPartitioner ()
520
516
modelname = f"vulkan_{ modelname } "
521
517
522
518
if args .mps :
@@ -545,7 +541,8 @@ def _export_llama(modelname, args) -> str: # noqa: C901
545
541
logging .info ("Generating etrecord" )
546
542
# Copy the edge manager which will be serialized into etrecord. This is memory-wise expensive.
547
543
edge_manager_copy = copy .deepcopy (builder_exported_to_edge .edge_manager )
548
- builder = builder_exported_to_edge .to_backend (partitioners ).to_executorch ()
544
+ # #pyre-ignore: pyre can't recognize the type of the instance
545
+ builder = builder_exported_to_edge .to_backend (partitioner ).to_executorch ()
549
546
550
547
# Generate ETRecord
551
548
if edge_manager_copy :
@@ -556,7 +553,8 @@ def _export_llama(modelname, args) -> str: # noqa: C901
556
553
)
557
554
logging .info ("Generated etrecord.bin" )
558
555
else :
559
- builder = builder_exported_to_edge .to_backend (partitioners ).to_executorch ()
556
+ # #pyre-ignore: pyre can't recognize the type of the instance
557
+ builder = builder_exported_to_edge .to_backend (partitioner ).to_executorch ()
560
558
561
559
if args .profile_memory :
562
560
generate_memory_trace (builder .export_program , "memory_profile.json" )
0 commit comments