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

Class _MockOp

tensorflow/python/eager/backprop.py:90–113  ·  view source on GitHub ↗

Pretends to be a tf.Operation for the gradient functions.

Source from the content-addressed store, hash-verified

88
89
90class _MockOp(object):
91 """Pretends to be a tf.Operation for the gradient functions."""
92
93 def __init__(self, attrs, inputs, outputs, typ, skip_input_indices):
94 self.attrs = attrs
95 self.inputs = inputs
96 self.outputs = outputs
97 self.type = typ
98 self.skip_input_indices = skip_input_indices
99
100 def get_attr(self, attr):
101 typ = op_attr_type(self.type, attr)
102 for i in range(0, len(self.attrs), 2):
103 if self.attrs[i] == attr:
104 return make_attr(typ, self.attrs[i + 1])
105 raise KeyError(attr)
106
107 def _get_control_flow_context(self):
108 raise NotImplementedError(
109 "tf.GradientTape.gradients() does not support graph control flow "
110 "operations like tf.cond or tf.while at this time. Use tf.gradients() "
111 "instead. If you need this feature, please file a feature request at "
112 "https://github.com/tensorflow/tensorflow/issues/new"
113 )
114
115
116def _gradient_function(op_name, attr_tuple, num_inputs, inputs, outputs,

Callers 4

_gradient_functionFunction · 0.85
testThreadsMethod · 0.85

Calls

no outgoing calls

Tested by 3

testThreadsMethod · 0.68