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

Method __call__

tensorflow/contrib/graph_editor/tests/match.py:86–125  ·  view source on GitHub ↗

Evaluate if the op matches or not.

(self, op)

Source from the content-addressed store, hash-verified

84 raise ValueError("Cannot finalize the positive filter: {}".format(elem))
85
86 def __call__(self, op):
87 """Evaluate if the op matches or not."""
88 if not isinstance(op, tf_ops.Operation):
89 raise TypeError("Expect tf.Operation, got: {}".format(type(op)))
90 for positive_filter in self.positive_filters:
91 if not positive_filter(op):
92 return False
93 if self.input_op_matches is not None:
94 if len(op.inputs) != len(self.input_op_matches):
95 return False
96 for input_t, input_op_match in zip(op.inputs, self.input_op_matches):
97 if input_op_match is None:
98 continue
99 if not input_op_match(input_t.op):
100 return False
101 if self.control_input_op_matches is not None:
102 if len(op.control_inputs) != len(self.control_input_op_matches):
103 return False
104 for cinput_op, cinput_op_match in zip(op.control_inputs,
105 self.control_input_op_matches):
106 if cinput_op_match is None:
107 continue
108 if not cinput_op_match(cinput_op):
109 return False
110 if self.output_op_matches is not None:
111 if len(op.outputs) != len(self.output_op_matches):
112 return False
113 for output_t, output_op_matches in zip(op.outputs,
114 self.output_op_matches):
115 if output_op_matches is None:
116 continue
117 if len(output_t.consumers()) != len(output_op_matches):
118 return False
119 for consumer_op, consumer_op_match in zip(output_t.consumers(),
120 output_op_matches):
121 if consumer_op_match is None:
122 continue
123 if not consumer_op_match(consumer_op):
124 return False
125 return True
126
127 def input_ops(self, *args):
128 """Add input matches."""

Callers

nothing calls this directly

Calls 3

typeFunction · 0.85
formatMethod · 0.45
consumersMethod · 0.45

Tested by

no test coverage detected