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

Class FlagBasedPartitioner

backends/vulkan/test/utils.py:93–124  ·  view source on GitHub ↗

Partitioner that partitions based on whether node.meta["custom"][field] is set to True.

Source from the content-addressed store, hash-verified

91
92
93class FlagBasedPartitioner(Partitioner):
94 """
95 Partitioner that partitions based on whether node.meta["custom"][field] is set to
96 True.
97 """
98
99 def __init__(self, field: str) -> None:
100 super().__init__()
101 self.field = field
102 self.delegation_spec = DelegationSpec("custom_partition", [])
103
104 def partition(self, exported_program: ExportedProgram) -> PartitionResult:
105 capability_partitioner = CapabilityBasedPartitioner(
106 exported_program.graph_module,
107 NodeFlagIsSetChecker(self.field),
108 allows_single_node_partition=True,
109 )
110 partition_list = capability_partitioner.propose_partitions()
111
112 partition_tags = {}
113 for partition in partition_list:
114 for node in partition.nodes:
115 tag = f"tag{partition.id}"
116 node.meta["delegation_tag"] = tag
117 partition_tags[tag] = self.delegation_spec
118
119 tag_constant_data(exported_program)
120 tag_mutated_buffer(exported_program)
121
122 return PartitionResult(
123 tagged_exported_program=exported_program, partition_tags=partition_tags
124 )
125
126
127def mark_node_range(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected