Register an OpDef. May call apply_op with the name afterwards.
(self, op_def)
| 290 | |
| 291 | # pylint: disable=invalid-name |
| 292 | def add_op(self, op_def): |
| 293 | """Register an OpDef. May call apply_op with the name afterwards.""" |
| 294 | if not isinstance(op_def, op_def_pb2.OpDef): |
| 295 | raise TypeError("%s is %s, not an op_def_pb2.OpDef" % |
| 296 | (op_def, type(op_def))) |
| 297 | if not op_def.name: |
| 298 | raise ValueError("%s missing name." % op_def) |
| 299 | if op_def.name in self._ops: |
| 300 | raise RuntimeError("Op name %s registered twice." % op_def.name) |
| 301 | self._ops[op_def.name] = _OpInfo(op_def) |
| 302 | |
| 303 | def add_op_list(self, op_list): |
| 304 | """Register the OpDefs from an OpList.""" |