Creates an `Operation` in this graph from the supplied TF_Operation. This method is like create_op() except the new Operation is constructed using `c_op`. The returned Operation will have `c_op` as its _c_op field. This is used to create Operation objects around TF_Operations created
(self, c_op, compute_device=True)
| 3432 | return ret |
| 3433 | |
| 3434 | def _create_op_from_tf_operation(self, c_op, compute_device=True): |
| 3435 | """Creates an `Operation` in this graph from the supplied TF_Operation. |
| 3436 | |
| 3437 | This method is like create_op() except the new Operation is constructed |
| 3438 | using `c_op`. The returned Operation will have `c_op` as its _c_op |
| 3439 | field. This is used to create Operation objects around TF_Operations created |
| 3440 | indirectly by the C API (e.g. by TF_ImportGraphDef, TF_FinishWhile). |
| 3441 | |
| 3442 | This function does not call Operation._control_flow_post_processing or |
| 3443 | Graph._control_dependencies_for_inputs (since the inputs may not be |
| 3444 | available yet). The caller is responsible for calling these methods. |
| 3445 | |
| 3446 | Args: |
| 3447 | c_op: a wrapped TF_Operation |
| 3448 | compute_device: (Optional.) If True, device functions will be executed to |
| 3449 | compute the device property of the Operation. |
| 3450 | |
| 3451 | Returns: |
| 3452 | An `Operation` object. |
| 3453 | """ |
| 3454 | self._check_not_finalized() |
| 3455 | ret = Operation(c_op, self) |
| 3456 | # If a name_scope was created with ret.name but no nodes were created in it, |
| 3457 | # the name will still appear in _names_in_use even though the name hasn't |
| 3458 | # been used. This is ok, just leave _names_in_use as-is in this case. |
| 3459 | # TODO(skyewm): make the C API guarantee no name conflicts. |
| 3460 | name_key = ret.name.lower() |
| 3461 | if name_key not in self._names_in_use: |
| 3462 | self._names_in_use[name_key] = 1 |
| 3463 | self._create_op_helper(ret, compute_device=compute_device) |
| 3464 | return ret |
| 3465 | |
| 3466 | def _create_op_helper(self, op, compute_device=True): |
| 3467 | """Common logic for creating an op in this graph.""" |