MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RerouteTensor

Function RerouteTensor

tensorflow/contrib/quantize/python/common.py:137–160  ·  view source on GitHub ↗

Reroute the end of the tensor t0 to the ends of the tensor t1. Args: t0: a tf.Tensor. t1: a tf.Tensor. can_modify: iterable of operations which can be modified. Any operation outside within_ops will be left untouched by this function. Returns: The number of individual mod

(t0, t1, can_modify=None)

Source from the content-addressed store, hash-verified

135
136
137def RerouteTensor(t0, t1, can_modify=None):
138 """Reroute the end of the tensor t0 to the ends of the tensor t1.
139
140 Args:
141 t0: a tf.Tensor.
142 t1: a tf.Tensor.
143 can_modify: iterable of operations which can be modified. Any operation
144 outside within_ops will be left untouched by this function.
145
146 Returns:
147 The number of individual modifications made by the function.
148 """
149 nb_update_inputs = 0
150 consumers = t1.consumers()
151 if can_modify is not None:
152 consumers = [c for c in consumers if c in can_modify]
153 consumers_indices = {}
154 for c in consumers:
155 consumers_indices[c] = [i for i, t in enumerate(c.inputs) if t is t1]
156 for c in consumers:
157 for i in consumers_indices[c]:
158 c._update_input(i, t0) # pylint: disable=protected-access
159 nb_update_inputs += 1
160 return nb_update_inputs

Callers

nothing calls this directly

Calls 2

_update_inputMethod · 0.80
consumersMethod · 0.45

Tested by

no test coverage detected