TrainableBlock refers to a limited subgraph extracted from integrated computational graph. TrainableBlock have exact one input node and one output node, while its depth(the distance from input node to output node) is limited. Formal definition of TrainableBlock can be found with fol
| 170 | |
| 171 | |
| 172 | class TrainableBlock: |
| 173 | """TrainableBlock refers to a limited subgraph extracted from integrated |
| 174 | computational graph. TrainableBlock have exact one input node and one |
| 175 | output node, while its depth(the distance from input node to output node) |
| 176 | is limited. |
| 177 | |
| 178 | Formal definition of TrainableBlock can be found with following code of BlockBuilder |
| 179 | |
| 180 | Minimal TrainableBlock is {p, p, {p}}, this block have only one node as both input and output. |
| 181 | """ |
| 182 | def __init__(self, sp: Operation, ep: Operation, rps: List[Operation]) -> None: |
| 183 | self.sp = sp # 起始节点 |
| 184 | self.ep = ep # 终止节点 |
| 185 | self.rps = rps # 中继节点 |
| 186 | |
| 187 | def __str__(self) -> str: |
| 188 | return f'[Graph Block from {self.sp.name} to {self.ep.name}]' |
| 189 | |
| 190 | |
| 191 | class BlockBuilder: |