Like Graph.create_op, except handles external input tensors. This overload adds functionality to create_op to "capture" any external input tensors, i.e. tensors from the eager context or outer function graphs if this is a nested function. See `capture` for more information. Args:
(
self,
op_type,
inputs,
dtypes=None, # pylint: disable=redefined-outer-name
input_types=None,
name=None,
attrs=None,
op_def=None,
compute_shapes=True,
compute_device=True)
| 477 | return captured_value.op |
| 478 | |
| 479 | def create_op( |
| 480 | self, |
| 481 | op_type, |
| 482 | inputs, |
| 483 | dtypes=None, # pylint: disable=redefined-outer-name |
| 484 | input_types=None, |
| 485 | name=None, |
| 486 | attrs=None, |
| 487 | op_def=None, |
| 488 | compute_shapes=True, |
| 489 | compute_device=True): |
| 490 | """Like Graph.create_op, except handles external input tensors. |
| 491 | |
| 492 | This overload adds functionality to create_op to "capture" any external |
| 493 | input tensors, i.e. tensors from the eager context or outer function graphs |
| 494 | if this is a nested function. See `capture` for more information. |
| 495 | |
| 496 | Args: |
| 497 | op_type: The `Operation` type to create. This corresponds to the |
| 498 | `OpDef.name` field for the proto that defines the operation. |
| 499 | inputs: A list of `Tensor` objects that will be inputs to the `Operation`. |
| 500 | dtypes: (Optional) A list of `DType` objects that will be the types of the |
| 501 | tensors that the operation produces. |
| 502 | input_types: (Optional.) A list of `DType`s that will be the types of |
| 503 | the tensors that the operation consumes. By default, uses the base |
| 504 | `DType` of each input in `inputs`. Operations that expect |
| 505 | reference-typed inputs must specify `input_types` explicitly. |
| 506 | name: (Optional.) A string name for the operation. If not specified, a |
| 507 | name is generated based on `op_type`. |
| 508 | attrs: (Optional.) A dictionary where the key is the attribute name (a |
| 509 | string) and the value is the respective `attr` attribute of the |
| 510 | `NodeDef` proto that will represent the operation (an `AttrValue` |
| 511 | proto). |
| 512 | op_def: (Optional.) The `OpDef` proto that describes the `op_type` that |
| 513 | the operation will have. |
| 514 | compute_shapes: (Optional.) Deprecated. Has no effect (shapes are always |
| 515 | computed). |
| 516 | compute_device: (Optional.) If True, device functions will be executed |
| 517 | to compute the device property of the Operation. |
| 518 | |
| 519 | Returns: |
| 520 | An `Operation` object. |
| 521 | """ |
| 522 | del compute_shapes |
| 523 | if self.capture_by_value and op_type in ["ReadVariableOp", |
| 524 | "ResourceGather"]: |
| 525 | return self._capture_by_value(op_type, inputs, dtypes, input_types, name, |
| 526 | attrs, op_def, compute_device) |
| 527 | |
| 528 | # This capturing logic interacts poorly with control flow contexts which |
| 529 | # want to replace inputs of ops far too late in the process. This can lead |
| 530 | # the context to get confused and try to create an Enter for an Enter. We |
| 531 | # can detect this here and skip the additional Enter which can confuse loop |
| 532 | # validation logic. |
| 533 | if op_type == "Enter" and inputs[0].op.type == "Enter": |
| 534 | if inputs[0].op.get_attr("frame_name") == attrs["frame_name"].s: |
| 535 | return inputs[0].op |
| 536 | # Calling AddValue on the control flow contexts to force creation of the |
nothing calls this directly
no test coverage detected