class_docstr: One kind of mapping of a logical mesh to a physical mesh.
class_docstr_tok: ["One","kind","of","mapping","of","a","logical","mesh","to","a","physical","mesh","."]
docstr: Constructs a HierarchicalTiling.
  
  spec is a list corresponding to the logical dimensions.
  
  spec[i] corresponds to the i-th logical dimension and consists of a name
    and a list of integers, the list being the shape of logical axis i when
    it is physically projected to the physical mesh and then compacted.
  
  Striding information is omitted.  By convention, the earlier dimensions
    get more strided. so the axis corresponding to the last dimension always
    gets projected to the tile specified by its shape.
  
  Args:
    spec: a list of (string, list-of-integers) pairs
    physical_shape: a list of integers
code: def __init__(self, spec, physical_shape):
      """Constructs a HierarchicalTiling.
  
      spec is a list corresponding to the logical dimensions.
  
      spec[i] corresponds to the i-th logical dimension and consists of a name
        and a list of integers, the list being the shape of logical axis i when
        it is physically projected to the physical mesh and then compacted.
  
      Striding information is omitted.  By convention, the earlier dimensions
        get more strided. so the axis corresponding to the last dimension always
        gets projected to the tile specified by its shape.
  
      Args:
        spec: a list of (string, list-of-integers) pairs
        physical_shape: a list of integers
      """
      self._names = [p[0] for p in spec]
      logical_ndims = len(spec)
      physical_ndims = len(physical_shape)
      projected_shapes = [p[1] for p in spec]
      if logical_ndims > 0 and projected_shapes[0] is None:
          # fill in missing value
          projected_shapes[0] = list(physical_shape)
          for s in projected_shapes[1:]:
              for i, x in enumerate(s):
                  projected_shapes[0][i] //= x
      # compute strides, and verify that the spec is valid.
      products = [1] * physical_ndims
      sizes_and_strides = []
      for s in reversed(projected_shapes):
          sizes_and_strides.append(
              [(size, stride) for size, stride in zip(s, products)]
          )
          for i, x in enumerate(s):
              products[i] *= x
      if products != physical_shape:
          raise ValueError(
              "mesh spec multiplies to the wrong size"
              "spec=%s physical_shape=%s products=%s"
              % (spec, physical_shape, products)
          )
      sizes_and_strides.reverse()
      self._physical_coordinates = _logical_to_physical_v1(
          sizes_and_strides, physical_shape
      )
      self._logical_to_physical = [
          mtf.processor_coordinates_to_pnum(physical_shape, c)
          for c in self._physical_coordinates
      ]
      self._mesh_shape = mtf.Shape(
          [
              mtf.Dimension(name, mtf.list_product(s))
              for name, s in zip(self._names, projected_shapes)
          ]
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  import os
  import gin
  from mesh_tensorflow import ops_with_redefined_builtins
  from mesh_tensorflow import tpu_variables
  from mesh_tensorflow import utils
  from six.moves import xrange
  import tensorflow.compat.v1
  from tensorflow.python.tpu.ops import tpu_ops
label_desc: Use image node_id 1 to create a new HierarchicalTiling object from inherited base classes: object with example: obj = HierarchicalTiling(spec, physical_shape)