(self, exported_program: ExportedProgram)
| 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 | |
| 127 | def mark_node_range( |
no test coverage detected