def _get_processor(var): """The processor of var.""" if context.executing_eagerly(): if isinstance(var, ops.Tensor): return optimizer._TensorProcessor(var) else: return optimizer._DenseResourceVariableProcessor(var) if isinstance(var, resource_variable_ops.ResourceVariable) and not var._in_graph_mode: # True if and only if `var` was initialized eagerly. return optimizer._DenseResourceVariableProcessor(var) if var.op.type == "VarHandleOp": return optimizer._DenseResourceVariableProcessor(var) if isinstance(var, variables.Variable): return _RefVariableProcessor(var) if isinstance(var, ops.Tensor): return optimizer._TensorProcessor(var) raise NotImplementedError("Trying to optimize unsupported type ", var)
def _get_processor(v): """The processor of v.""" if context.executing_eagerly(): if isinstance(v, ops.Tensor): return optimizer._TensorProcessor(v) else: return optimizer._DenseResourceVariableProcessor(v) if isinstance(v, de.TrainableWrapper): return _DenseDynamicEmbeddingTrainableProcessor(v) if (rvo.is_resource_variable(v) and not v._in_graph_mode): # pylint: disable=protected-access # True if and only if `v` was initialized eagerly. return optimizer._DenseResourceVariableProcessor(v) if v.op.type == "VarHandleOp": return optimizer._DenseResourceVariableProcessor(v) if isinstance(v, variables.Variable): return optimizer._RefVariableProcessor(v) if isinstance(v, ops.Tensor): return optimizer._TensorProcessor(v) raise NotImplementedError("Trying to optimize unsupported type ", v)