|
10 | 10 | from typing import Any, Callable, cast, Dict, List, Optional, Union
|
11 | 11 |
|
12 | 12 | import torch
|
| 13 | + |
| 14 | +from executorch.backends.xnnpack.partition.configs import ( |
| 15 | + SUPPORTED_DYN_QUANT_MODULES, |
| 16 | + SUPPORTED_MODULES, |
| 17 | + SUPPORTED_OPS, |
| 18 | + SUPPORTED_QUANT_MODULES, |
| 19 | + SUPPORTED_QUANT_OPS, |
| 20 | +) |
13 | 21 | from executorch.backends.xnnpack.partition.support_patterns import (
|
14 | 22 | get_add_graphs,
|
15 | 23 | get_all_dynamically_quantized_linear_pattern,
|
@@ -522,107 +530,6 @@ def __init__(self):
|
522 | 530 | )
|
523 | 531 |
|
524 | 532 |
|
525 |
| -### |
526 |
| -### Module based partitioners |
527 |
| -### |
528 |
| - |
529 |
| -SUPPORTED_OPS = [ |
530 |
| - exir_ops.edge.aten.div.Tensor, |
531 |
| - exir_ops.edge.aten.add.Tensor, |
532 |
| - exir_ops.edge.aten.clamp.default, |
533 |
| - exir_ops.edge.aten.sub.Tensor, |
534 |
| - exir_ops.edge.aten.floor.default, |
535 |
| - exir_ops.edge.aten.maximum.default, |
536 |
| - exir_ops.edge.aten.minimum.default, |
537 |
| - exir_ops.edge.aten.mul.Tensor, |
538 |
| - exir_ops.edge.aten.constant_pad_nd.default, |
539 |
| - exir_ops.edge.aten.upsample_bilinear2d.default, |
540 |
| - exir_ops.edge.aten.mean.dim, |
541 |
| - exir_ops.edge.aten.max.dim, |
542 |
| - exir_ops.edge.aten.hardtanh.default, |
543 |
| - exir_ops.edge.aten.sqrt.default, |
544 |
| - exir_ops.edge.aten.ceil.default, |
545 |
| - exir_ops.edge.aten.hardswish.default, |
546 |
| - exir_ops.edge.aten.neg.default, |
547 |
| - exir_ops.edge.aten.pow.Tensor_Scalar, |
548 |
| - exir_ops.edge.aten.abs.default, |
549 |
| - exir_ops.edge.aten._prelu_kernel.default, |
550 |
| - exir_ops.edge.aten.slice_copy.Tensor, |
551 |
| -] |
552 |
| - |
553 |
| -SUPPORTED_MODULES = [ |
554 |
| - torch.nn.Conv1d, |
555 |
| - torch.nn.Conv2d, |
556 |
| - torch.nn.ReLU, |
557 |
| - torch.nn.Sigmoid, |
558 |
| - torch.nn.Softmax, |
559 |
| - torch.nn.BatchNorm1d, |
560 |
| - torch.nn.BatchNorm2d, |
561 |
| - torch.nn.Linear, |
562 |
| - torch.nn.functional.linear, |
563 |
| - torch.nn.Hardtanh, |
564 |
| - torch.nn.MaxPool2d, |
565 |
| - torch.nn.LeakyReLU, |
566 |
| - torch.nn.ELU, |
567 |
| - torch.nn.AvgPool2d, |
568 |
| - torch.nn.PReLU, # Without this, the PReLU weight becomes not a get_attr |
569 |
| - torch.cat, |
570 |
| - torch.concat, |
571 |
| - torch.concatenate, |
572 |
| -] |
573 |
| - |
574 |
| -# TODO delete this and should use SUPPORTED_OPS instead once we align fp32 and quant support |
575 |
| -SUPPORTED_QUANT_OPS = [ |
576 |
| - exir_ops.edge.aten.add.Tensor, |
577 |
| - exir_ops.edge.aten.sub.Tensor, |
578 |
| - exir_ops.edge.aten.mul.Tensor, |
579 |
| - exir_ops.edge.aten.mean.dim, |
580 |
| - exir_ops.edge.aten.hardtanh.default, # TODO - which one module or op or both? |
581 |
| - exir_ops.edge.aten.slice_copy.Tensor, |
582 |
| -] |
583 |
| - |
584 |
| -# TODO delete this and should use SUPPORTED_MODULES instead once we align fp32 and quant support |
585 |
| -SUPPORTED_QUANT_MODULES = [ |
586 |
| - torch.clamp, |
587 |
| - torch.mean, |
588 |
| - torch.permute, |
589 |
| - torch.permute_copy, |
590 |
| - torch.cat, |
591 |
| - torch.concat, |
592 |
| - torch.concatenate, |
593 |
| - torch.nn.Linear, |
594 |
| - torch.nn.functional.linear, |
595 |
| - # TODO - T158982884 |
596 |
| - # torch.ao.nn.quantized.reference.modules.linear.Linear, |
597 |
| - torch.nn.MaxPool2d, |
598 |
| - torch.nn.Conv1d, |
599 |
| - torch.nn.functional.conv1d, |
600 |
| - torch.ao.nn.quantized.reference.modules.conv.Conv1d, |
601 |
| - torch.nn.Conv2d, |
602 |
| - torch.nn.functional.conv2d, |
603 |
| - torch.nn.functional.pad, |
604 |
| - torch.nn.functional.elu, |
605 |
| - torch.ao.nn.quantized.reference.modules.conv.Conv2d, |
606 |
| - torch.nn.BatchNorm1d, |
607 |
| - torch.nn.BatchNorm2d, |
608 |
| - torch.nn.ConstantPad2d, |
609 |
| - torch.nn.ELU, |
610 |
| - torch.nn.Hardtanh, |
611 |
| - torch.nn.ReLU, |
612 |
| - torch.nn.functional.relu, |
613 |
| - torch.nn.functional.relu_, |
614 |
| - torch.nn.functional.leaky_relu, |
615 |
| - torch.nn.functional.leaky_relu_, |
616 |
| - torch.nn.LeakyReLU, |
617 |
| -] |
618 |
| - |
619 |
| -# Modules which support dynamic quantization |
620 |
| -SUPPORTED_DYN_QUANT_MODULES = [ |
621 |
| - torch.nn.Linear, |
622 |
| - torch.nn.functional.linear, |
623 |
| -] |
624 |
| - |
625 |
| - |
626 | 533 | class XnnpackFloatingPointPartitioner(Partitioner):
|
627 | 534 | """
|
628 | 535 | Module and Opname based partitioner for FP32 modules/ops listed in
|
|
0 commit comments