def connection_pattern(self, node): """ Return connection pattern of subfgraph defined by inputs and outputs. """ if self._connection_pattern is not None: return self._connection_pattern inp_len = len(self.local_inputs) out_len = len(self.local_outputs) cpmat_self = io_connection_pattern(self.local_inputs, self.local_outputs) lop_op = self.get_lop_op() cpmat_grad = io_connection_pattern(lop_op.local_inputs[inp_len:], lop_op.local_outputs) # cpmat_self |= cpmat_grad.T # cpmat_self &= out_is_disconnected for i, t in enumerate(self._lop_op_stypes_l): if t is not None: if isinstance(t.type, DisconnectedType): for o in range(out_len): cpmat_self[i][o] = False for o in range(out_len): cpmat_self[i][o] |= cpmat_grad[o][i] # TODO in case DisconnectedType is implemented for R_op, # self._rop_op_stypes_l self._rop_op should considered for # connection_pattern return list(map(list, cpmat_self))
def connection_pattern(self, node): """ Return connection pattern of subfgraph defined by inputs and outputs. """ inp_len = len(self.local_inputs) out_len = len(self.local_outputs) cpmat_self = io_connection_pattern( self.local_inputs, self.local_outputs) grad_op = self.get_grad_op() cpmat_grad = io_connection_pattern( grad_op.local_inputs[inp_len:], grad_op.local_outputs) # cpmat_self |= cpmat_grad.T # cpmat_self &= out_is_disconnected for i, t in enumerate(self._grad_op_stypes_l): if t is not None: if isinstance(t.type, DisconnectedType): for o in range(out_len): cpmat_self[i][o] = False for o in range(out_len): cpmat_self[i][o] |= cpmat_grad[o][i] # TODO in case DisconnectedType is implemented for R_op, # self._rop_op_stypes_l self._rop_op should considered for # connection_pattern return list(map(list, cpmat_self))
def connection_pattern(self, node): """ Return connection pattern of subfgraph defined by inputs and outputs. """ return io_connection_pattern(self.new_inputs, self.new_outputs)
def connection_pattern(self, node): """ Return connection pattern of subfgraph defined by inputs and outputs. """ return io_connection_pattern(self.new_inputs, self.new_outputs)