Variable Utils¶
Common helpers for ResourceVariables and RefVariables.
-
is_read_var_op
(op, version=None)[source]¶ Determines if an op is a read var op.
Checks if it is a ReadVariableOp or an IdentityOp. This is because ResourceVariables use ReadVariableOps and RefVariables use IdentityOps.
-
get_read_var_ops
(var_op, exclude_snapshot=False)[source]¶ Given a resource handle op, get all its read variable ops.
- Parameters
var_op (Operation) – VarHandleOp for ResourceVariable, VariableV2 or Variable for RefVariable
exclude_snapshot (bool) – whether to skip the default ReadVariableOp bundled (i.e. “/Read/ReadVariableOp”). no extra snapshot to exclude for RefVariable, even if exclude_snapshot=True.
- Returns
List of read var ops of it.
- Return type
List[Operation]