parameters: (ndarray)
return_statement: return Shape(element_type, dimensions, layout)
docstring: Create a Shape from a given Numpy array.
  
    Args:
      ndarray: Numpy array.
  
    Returns:
      A Shape object.
docstring_summary: Create a Shape from a given Numpy array.
docstring_tokens: Create a Shape from a given Numpy array .
function: def _CreateShapeFromNumpy(ndarray):  # pylint: disable=invalid-name
    """Create a Shape from a given Numpy array.
  
    Args:
      ndarray: Numpy array.
  
    Returns:
      A Shape object.
    """
    element_type = types.MAP_DTYPE_TO_RECORD[str(ndarray.dtype)].primitive_type
    dimensions = ndarray.shape
  
    # Set the shape's layout based on the ordering of ndarray.
    # Numpy arrays come in two orders: Fortran (column-major) and C (row-major).
    if _np.isfortran(ndarray):
      # Column-major layout. This corresponds to a "dimension order is
      # minor-to-major" layout in XLA.
      layout = range(ndarray.ndim)
    else:
      # Row-major layout. This corresponds to a "dimension order is
      # major-to-minor" layout int XLA.
      layout = list(reversed(range(ndarray.ndim)))
  
    return Shape(element_type, dimensions, layout)
function_tokens: def _CreateShapeFromNumpy ( ndarray ) : # pylint: disable=invalid-name element_type = types . MAP_DTYPE_TO_RECORD [ str ( ndarray . dtype ) ] . primitive_type dimensions = ndarray . shape # Set the shape's layout based on the ordering of ndarray. # Numpy arrays come in two orders: Fortran (column-major) and C (row-major). if _np . isfortran ( ndarray ) : # Column-major layout. This corresponds to a "dimension order is # minor-to-major" layout in XLA. layout = range ( ndarray . ndim ) else : # Row-major layout. This corresponds to a "dimension order is # major-to-minor" layout int XLA. layout = list ( reversed ( range ( ndarray . ndim ) ) ) return Shape ( element_type , dimensions , layout )