MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _has_captured_ref

Method _has_captured_ref

tensorflow/python/data/ops/dataset_ops.py:232–253  ·  view source on GitHub ↗

Whether this dataset uses a function that captures ref variables. Returns: A boolean, which if true indicates that the dataset or one of its inputs uses a function that captures ref variables.

(self)

Source from the content-addressed store, hash-verified

230 raise ValueError("The _graph property is read-only")
231
232 def _has_captured_ref(self):
233 """Whether this dataset uses a function that captures ref variables.
234
235 Returns:
236 A boolean, which if true indicates that the dataset or one of its inputs
237 uses a function that captures ref variables.
238 """
239 if context.executing_eagerly():
240 # RefVariables are not supported in eager mode
241 return False
242
243 def is_tensor_or_parent_ref(tensor):
244 if tensor.dtype._is_ref_dtype: # pylint: disable=protected-access
245 return True
246 return any([is_tensor_or_parent_ref(x) for x in tensor.op.inputs])
247
248 for fn in self._functions():
249 if any([is_tensor_or_parent_ref(t) for t in fn.function.captured_inputs]):
250 return True
251
252 return any(
253 [input_dataset._has_captured_ref() for input_dataset in self._inputs()]) # pylint: disable=protected-access
254
255 # TODO(jsimsa): Change this to be the transitive closure of functions used
256 # by this dataset and its inputs.

Callers 2

_apply_optionsMethod · 0.95
_has_captured_refMethod · 0.45

Calls 4

_functionsMethod · 0.95
_inputsMethod · 0.95
anyFunction · 0.85
executing_eagerlyMethod · 0.80

Tested by

no test coverage detected