Return true if scalar output tensor from Op is not safe to be traced.
(op)
| 293 | |
| 294 | @staticmethod |
| 295 | def unsafe_scalar_trace(op): |
| 296 | """Return true if scalar output tensor from Op is not safe to be traced.""" |
| 297 | |
| 298 | # Tracing the following causes cycle in the graph on TPU. |
| 299 | if op.type in ('LoopCond', 'Enter', 'Merge', 'Const', |
| 300 | 'Switch', 'Less', 'ReadVariableOp'): |
| 301 | return True |
| 302 | # Tracing the following will cause casting-issue |
| 303 | # with the norm tracing mode or other compilation issues on CPU. |
| 304 | if op.type in ('VarHandleOp', 'IteratorToStringHandle', |
| 305 | 'IteratorGetNext', 'OneShotIterator', |
| 306 | 'IteratorV2', 'MakeIterator', |
| 307 | 'BatchDatasetV2', 'MapDataset', |
| 308 | 'FixedLengthRecordDataset', 'TakeDataset', 'ZipDataset', |
| 309 | 'Placeholder', 'PlaceholderWithDefault', 'StridedSlice'): |
| 310 | return True |
| 311 | return False |
| 312 | |
| 313 | def _less_interesting_op(self, op): |
| 314 | """Returns True if the given op is not an interesting one to be traced.""" |