Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backends/xnnpack/partition/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@
SubConfig,
TanhConfig,
ToDimOrderCopyConfig,
UnsqueezeCopyConfig,
UpsampleBilinear2dConfig,
ViewCopyConfig,
)
from executorch.backends.xnnpack.partition.config.node_configs import (
BatchNormConfig,
Expand Down Expand Up @@ -116,7 +118,9 @@
SoftmaxConfig,
SquareRootConfig,
SubConfig,
UnsqueezeCopyConfig,
UpsampleBilinear2dConfig,
ViewCopyConfig,
# Quant/Dequant Op Configs
QuantizedPerTensorConfig,
DeQuantizedPerTensorConfig,
Expand Down
23 changes: 22 additions & 1 deletion backends/xnnpack/partition/config/generic_node_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ class ViewCopyConfig(GenericNodePartitionerConfig):
target_name = "view_copy.default"

def supported_precision_types(self) -> List[ConfigPrecisionType]:
return [ConfigPrecisionType.FP32]
return [ConfigPrecisionType.FP32, ConfigPrecisionType.STATIC_QUANT]

def check_constraints(self, node: torch.fx.Node, ep: ExportedProgram) -> bool:
"""
Expand Down Expand Up @@ -722,3 +722,24 @@ class CosConfig(GenericNodePartitionerConfig):

def supported_precision_types(self) -> List[ConfigPrecisionType]:
return [ConfigPrecisionType.FP32]


class UnsqueezeCopyConfig(GenericNodePartitionerConfig):
target_name = "unsqueeze_copy.default"

def supported_precision_types(self) -> List[ConfigPrecisionType]:
return [ConfigPrecisionType.FP32, ConfigPrecisionType.STATIC_QUANT]

def check_constraints(self, node: torch.fx.Node, ep: ExportedProgram) -> bool:
if not self.check_common_constraints(node, ep):
return False

# The XNNPACK UnsqueezeVisitor only supports unsqueeze on the trailing
# dimension. Mirrors the runtime check in op_squeeze.py.
dim = node.args[1]
input_rank = len(node.args[0].meta["val"].shape)
if dim != -1 and dim != input_rank:
why(node, reason="unsqueeze_copy only supported on the trailing dimension")
return False

return True
Loading