| 1542 | |
| 1543 | |
| 1544 | def AppendNet(self, net, device_option=None): |
| 1545 | assert isinstance(net, Net) |
| 1546 | for i in net.Proto().external_input: |
| 1547 | if ( |
| 1548 | i not in self.Proto().external_input and |
| 1549 | i not in self._op_outputs |
| 1550 | ): |
| 1551 | self.Proto().external_input.append(i) |
| 1552 | |
| 1553 | self.Proto().external_output.extend( |
| 1554 | [ |
| 1555 | o for o in net.Proto().external_output |
| 1556 | if o not in self.Proto().external_output |
| 1557 | ] |
| 1558 | ) |
| 1559 | ops = net.Proto().op |
| 1560 | if device_option is not None: |
| 1561 | ops = [copy.deepcopy(op) for op in ops] |
| 1562 | for op in ops: |
| 1563 | op.device_option.CopyFrom(device_option) |
| 1564 | for op in ops: |
| 1565 | if op.type == "RecurrentNetwork": |
| 1566 | for arg in op.arg: |
| 1567 | if arg.name.endswith('step_net'): |
| 1568 | for step_op in arg.n.op: |
| 1569 | step_op.device_option.CopyFrom(device_option) |
| 1570 | |
| 1571 | self._ExtendOps(ops) |
| 1572 | return self |
| 1573 | |
| 1574 | def LogInfo(self, *msg_or_blobs): |
| 1575 | for msg_or_blob in msg_or_blobs: |