parameters: (op)
docstring: Shape function for Bitcast op.
docstring_summary: Shape function for Bitcast op.
docstring_tokens: Shape function for Bitcast op .
function: def _BitcastShape(op):
    """Shape function for Bitcast op."""
    input_shape = op.inputs[0].get_shape()
    if input_shape == tensor_shape.unknown_shape():
      return [tensor_shape.unknown_shape()]
    input_type = op.inputs[0].dtype
    size_of_input = input_type.size
    output = dtypes.as_dtype(op.get_attr("type"))
    size_of_output = output.size
    if size_of_input == size_of_output:
      return [input_shape]
    else:
      if size_of_output > size_of_input:
        new_shape = input_shape.with_rank_at_least(1).as_list()
        last_val = new_shape[-1]
        if last_val is None or last_val == (size_of_output // size_of_input):
          new_shape = new_shape[:-1]
        else:
          raise ValueError(
              "Cannot bitcast due to shape. %d is not evenly divisible by %d." %
              (new_shape[-1], size_of_input // size_of_output))
      else:
        new_shape = input_shape
        new_shape = new_shape.concatenate([size_of_input // size_of_output])
      return [tensor_shape.TensorShape(new_shape)]
function_tokens: def _BitcastShape ( op ) : input_shape = op . inputs [ 0 ] . get_shape ( ) if input_shape == tensor_shape . unknown_shape ( ) : return [ tensor_shape . unknown_shape ( ) ] input_type = op . inputs [ 0 ] . dtype size_of_input = input_type . size output = dtypes . as_dtype ( op . get_attr ( "type" ) ) size_of_output = output . size if size_of_input == size_of_output : return [ input_shape ] else : if size_of_output > size_of_input : new_shape = input_shape . with_rank_at_least ( 1 ) . as_list ( ) last_val = new_shape [ - 1 ] if last_val is None or last_val == ( size_of_output // size_of_input ) : new_shape = new_shape [ : - 1 ] else : raise ValueError ( "Cannot bitcast due to shape. %d is not evenly divisible by %d." % ( new_shape [ - 1 ] , size_of_input // size_of_output ) ) else : new_shape = input_shape new_shape = new_shape . concatenate ( [ size_of_input // size_of_output ] ) return [ tensor_shape . TensorShape ( new_shape ) ]