Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def apply_op(self, op_type_name, name=None, **keywords):
- # pylint: disable=g-doc-args
- """ Add a node invoking a registered Op to a graph.
- (skip other explaination)
- """
- # Determine the graph context.
- try:
- g = ops._get_graph_from_inputs(_Flatten(keywords.values()))
- except AssertionError as e:
- raise RuntimeError(
- "Cannot determine graph for Op '%s' due to: %s"
- % (op_type_name, e.message))
- """
- ...
- (Skip detail)
- ...
- """
- with g.as_default(), ops.name_scope(name) as scope:
- """
- ...
- (Skip detail)
- ...
- """
- with _MaybeColocateWith(must_colocate_inputs):
- # Add Op to graph
- op = g.create_op(op_type_name, inputs, output_types, name=scope,
- input_types=input_types, attrs=attr_protos,
- op_def=op_def)
- if output_structure:
- outputs = op.outputs
- res = _Restructure(ops.convert_n_to_tensor(outputs), output_structure)
- if isinstance(res, list) and not res and op_def.is_stateful:
- return op
- else:
- return res
- else:
- return op
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement