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)
| 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. |
no test coverage detected