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

Method _skip_tensor

tensorflow/python/tpu/tensor_tracer.py:811–883  ·  view source on GitHub ↗

Returns True if we should not trace out_tensor. Args: op_id: Topological index of the op producing tensor. out_tensor: tf.Tensor report_handler: An instance of tensor_tracer_report.TTReportHandle. Returns: True if the tensor should not be traced, false otherwise.

(self, op_id, out_tensor, report_handler)

Source from the content-addressed store, hash-verified

809 return False
810
811 def _skip_tensor(self, op_id, out_tensor, report_handler):
812 """Returns True if we should not trace out_tensor.
813
814 Args:
815 op_id: Topological index of the op producing tensor.
816 out_tensor: tf.Tensor
817 report_handler: An instance of tensor_tracer_report.TTReportHandle.
818 Returns:
819 True if the tensor should not be traced, false otherwise.
820 """
821
822 # Skips a tensor if the tensor has a non-numeric type.
823 # Note: we cannot use check_ops.is_numeric_tensor(out_tensor)
824 # because it also excludes tensors with dtypes, bool, and
825 # float32_ref, which we actually want to trace.
826 non_numeric_tensor_types = set([dtypes.variant, dtypes.resource,
827 dtypes.string])
828 if out_tensor.dtype in non_numeric_tensor_types:
829
830 report_handler.instrument_tensor(
831 out_tensor, TensorTracer.reason(op_id, _REASON_NON_NUMERIC_TENSOR))
832 return True
833 # Skip a tensor if it feeds a special while loop op.
834 if [consumer for consumer in out_tensor.consumers() if
835 TensorTracer.while_loop_op(consumer)]:
836 report_handler.instrument_tensor(
837 out_tensor, TensorTracer.reason(op_id, _REASON_FEEDS_WHILELOOP_OP))
838 return True
839 if self._is_user_included_op(out_tensor.op):
840 report_handler.instrument_tensor(
841 out_tensor, TensorTracer.reason(op_id, _REASON_USER_INCLUDED))
842 return False
843 if self._is_user_excluded_op(out_tensor.op):
844 report_handler.instrument_tensor(
845 out_tensor, TensorTracer.reason(op_id, _REASON_USER_EXCLUDED))
846 return True
847 if not out_tensor.get_shape().is_fully_defined():
848 # If trace mode is nan-inf, norm or max, then the tensor will be reduced
849 # to a scalar before the outside compilation call.
850 if self._parameters.trace_mode in (
851 tensor_tracer_flags.TRACE_MODE_NAN_INF,
852 tensor_tracer_flags.TRACE_MODE_NORM,
853 tensor_tracer_flags.TRACE_MODE_MAX_ABS,
854 tensor_tracer_flags.TRACE_MODE_SUMMARY
855 ):
856 report_handler.instrument_tensor(
857 out_tensor, TensorTracer.reason(op_id, _REASON_TENSOR_GET_TRACED))
858 return False
859 else:
860 report_handler.instrument_tensor(
861 out_tensor, TensorTracer.reason(op_id, _REASON_DYNAMIC_SHAPE))
862 return True
863 rank = len(out_tensor.shape)
864 if rank < 1:
865 # scalar
866 if self._parameters.trace_scalar_ops:
867 if TensorTracer.unsafe_scalar_trace(out_tensor.op):
868 report_handler.instrument_tensor(

Calls 9

_is_user_included_opMethod · 0.95
_is_user_excluded_opMethod · 0.95
instrument_tensorMethod · 0.80
reasonMethod · 0.80
while_loop_opMethod · 0.80
is_fully_definedMethod · 0.80
unsafe_scalar_traceMethod · 0.80
consumersMethod · 0.45
get_shapeMethod · 0.45

Tested by

no test coverage detected