class_docstr: Wraps a xla_data_pb2.ShapeProto message with a convenient Python type.
  
  Provides direct access to the underlying xla_data_pb2.ShapeProto message in
  the
  message attribute, along with accessor wrappers to the message's fields.
  Avoid direct access to .message unless interacting directly with protobuf APIs
  like CopyFrom. In other words, prefer hauling the shape around in a Shape, and
  only access .message when strictly required by the protobuf API.
class_docstr_tok: ["Wraps","a","xla_data_pb2.ShapeProto","message","with","a","convenient","Python","type",".","Provides","direct","access","to","the","underlying","xla_data_pb2.ShapeProto","message","in","the","message","attribute",",","along","with","accessor","wrappers","to","the","message","'s","fields",".","Avoid","direct","access","to",".message","unless","interacting","directly","with","protobuf","APIs","like","CopyFrom",".","In","other","words",",","prefer","hauling","the","shape","around","in","a","Shape",",","and","only","access",".message","when","strictly","required","by","the","protobuf","API","."]
docstr: Creates a new XLA Shape.
  
  Args:
    element_type: element type from xla_data_pb2.
    dimensions: sequence of dimensions sizes (integers), or sequence
      of Shapes in the case of a tuple, i.e. when element_type is
      TUPLE.
    layout: optional minor_to_major sequence for layout. If not given, the
      default major-to-minor layout is used.
  
  Raises:
    ValueError: if element_type is TUPLE but dimensions are not Shape objects.
docstr_tok: ["Creates","a","new","XLA","Shape",".","Args",":","element_type",":","element","type","from","xla_data_pb2",".","dimensions",":","sequence","of","dimensions","sizes","(","integers",")",",","or","sequence","of","Shapes","in","the","case","of","a","tuple",",","i.e",".","when","element_type","is","TUPLE",".","layout",":","optional","minor_to_major","sequence","for","layout",".","If","not","given",",","the","default","major-to-minor","layout","is","used",".","Raises",":","ValueError",":","if","element_type","is","TUPLE","but","dimensions","are","not","Shape","objects","."]
code: def __init__(self, element_type, dimensions, layout=None):
      """Creates a new XLA Shape.
  
      Args:
        element_type: element type from xla_data_pb2.
        dimensions: sequence of dimensions sizes (integers), or sequence
          of Shapes in the case of a tuple, i.e. when element_type is
          TUPLE.
        layout: optional minor_to_major sequence for layout. If not given, the
          default major-to-minor layout is used.
  
      Raises:
        ValueError: if element_type is TUPLE but dimensions are not Shape objects.
      """
      self.message = xla_data_pb2.ShapeProto()
      self.message.element_type = element_type
      if element_type == xla_data_pb2.TUPLE:
          if not all(
              isinstance(subshape, Shape) for subshape in dimensions
          ):
              raise ValueError(
                  "XLA tuple requires sequence of Shape objects as dimensions"
              )
          self._tuple_shapes = tuple(dimensions)
          for component_shape in self._tuple_shapes:
              component_message = self.message.tuple_shapes.add()
              component_message.CopyFrom(component_shape.message)
      else:
          self.message.dimensions.extend(dimensions)
          if layout is None:
              layout = list(reversed(range(len(dimensions))))
          self.message.layout.minor_to_major.extend(layout)
  
file_path: tensorflow/third_party/xla/xla/python_api/xla_shape.py
imports: import numpy
  from local_xla.xla import xla_data_pb2
  from xla.python_api import types_
label_desc: Use image node_id 1 to create a new Shape object from inherited base classes: object with example: obj = Shape(element_type, dimensions, layout)