parameters: (src_spec, desired_spec)
return_statement: return True
docstring: Check whether two tensor type spec is compatible.
docstring_summary: Check whether two tensor type spec is compatible.
docstring_tokens: Check whether two tensor type spec is compatible .
function: def _compatible_tensor_spec(src_spec, desired_spec):
      """
      Check whether two tensor type spec is compatible.
      """
      for spec in [src_spec, desired_spec]:
          if not isinstance(spec, paddle.static.InputSpec):
              return False
      src_shape = src_spec.shape
      other_shape = desired_spec.shape
      len_shape = len(src_shape)
      if len_shape != len(other_shape):
          return False
      for j in range(len_shape):
          if src_shape[j] is None or src_shape[j] < 0:
              continue
          if other_shape[j] is None or other_shape[j] < 0:
              continue
          if src_shape[j] != other_shape[j]:
              return False
  
      src_dtype = convert_dtype(src_spec.dtype)
      other_dtype = convert_dtype(desired_spec.dtype)
      if src_dtype != other_dtype:
          return False
  
      return True
function_tokens: def _compatible_tensor_spec ( src_spec , desired_spec ) : for spec in [ src_spec , desired_spec ] : if not isinstance ( spec , paddle . static . InputSpec ) : return False src_shape = src_spec . shape other_shape = desired_spec . shape len_shape = len ( src_shape ) if len_shape != len ( other_shape ) : return False for j in range ( len_shape ) : if src_shape [ j ] is None or src_shape [ j ] < 0 : continue if other_shape [ j ] is None or other_shape [ j ] < 0 : continue if src_shape [ j ] != other_shape [ j ] : return False src_dtype = convert_dtype ( src_spec . dtype ) other_dtype = convert_dtype ( desired_spec . dtype ) if src_dtype != other_dtype : return False return True