What does `Graph.create_op` do?

I am trying to figure out tf.function converts a python function to a graph and calls it. And I have found that in tensorflow/python/ops/functional_ops.py:partitioned_call,

op = graph.create_op(op_name, args, tout, name=op_name, attrs=op_attrs)
outputs = op.outputs

It seems that the graph is converted to an operation, but when I read the documentation of Operation , it says

An Operation is a node in a tf.Graph that takes zero or more Tensor
objects as input, and produces zero or more Tensor objects as output.

So I assume that Operation should be a node in the graph. That makes me wonder what graph.create_op really does. Is graph converted into a big Operation here?

Is graph converted into a big Operation here?

That is my understanding. That functions in the tensorflow runtime are implemented as a separate (partitioned) graph, and called from the main graph as if they were a regular Op.

2 Likes