class_docstr: tf.Graph & mtf.Graph common representation which produces a CostGraphDef.
  
  Attributes:
    canonical_device: string or None, the name of the canonical device for
        is_tensor_on_canonical_device
  
  Usage Example:
    mtf_graph = mtf.Graph()
    # Add operations to mtf_graph using Mesh TensorFlow.
    graph = graph_interface.GraphInterface(mtf_graph)
    for operation_name in graph.get_all_operation_names():
      print("Operation: {}".format(operation_name))
      for input_name in graph.get_operation_input_names(operation_name):
        print("  Input: {}".format(input_name))
      for output_name in graph.get_operation_output_names(operation_name):
        print("  Output: {}".format(output_name))
        # Tensor names can also be used to retrieve data type, shape, and Mesh
        # TensorFlow dimension names.
      # Operation names can also be used to get Mesh TensorFlow dimension names.
    cost_graph = graph.compute_cost_graph()
    # Give cost_graph to a scheduler to compute schedule.
    memory_contents = graph.compute_memory_contents_under_schedule(schedule)
class_docstr_tok: ["tf.Graph","&","mtf.Graph","common","representation","which","produces","a","CostGraphDef",".","Attributes",":","canonical_device",":","string","or","None",",","the","name","of","the","canonical","device","for","is_tensor_on_canonical_device","Usage","Example",":","mtf_graph","=","mtf.Graph","(",")","#","Add","operations","to","mtf_graph","using","Mesh","TensorFlow",".","graph","=","graph_interface.GraphInterface","(","mtf_graph",")","for","operation_name","in","graph.get_all_operation_names","(",")",":","print","(","``","Operation",":","{","}","''",".format","(","operation_name",")",")","for","input_name","in","graph.get_operation_input_names","(","operation_name",")",":","print","(","``","Input",":","{","}","''",".format","(","input_name",")",")","for","output_name","in","graph.get_operation_output_names","(","operation_name",")",":","print","(","``","Output",":","{","}","''",".format","(","output_name",")",")","#","Tensor","names","can","also","be","used","to","retrieve","data","type",",","shape",",","and","Mesh","#","TensorFlow","dimension","names",".","#","Operation","names","can","also","be","used","to","get","Mesh","TensorFlow","dimension","names",".","cost_graph","=","graph.compute_cost_graph","(",")","#","Give","cost_graph","to","a","scheduler","to","compute","schedule",".","memory_contents","=","graph.compute_memory_contents_under_schedule","(","schedule",")"]
docstr: The in-memory tensors present when executing each operation in schedule.
  
  Simulates running operations in the order given by a schedule. Keeps track
  of the tensors in memory at every point in time, and outputs a list (one
  entry for each point in time) of all sets of all memory contents (i.e. a
  frozenset of strings) ever seen in this execution.
  
  It is assumed (but not checked) that schedule is a valid topological sort of
  the operations in this graph.
  
  Args:
    schedule: A list of integer ids; the order to run operations in.
  
  Returns:
    a list of frozenset of strings, where the ith entry describes the tensors
    in memory when executing operation i (where schedule[i] is an index into
    get_all_operation_names()).
docstr_tok: ["The","in-memory","tensors","present","when","executing","each","operation","in","schedule",".","Simulates","running","operations","in","the","order","given","by","a","schedule",".","Keeps","track","of","the","tensors","in","memory","at","every","point","in","time",",","and","outputs","a","list","(","one","entry","for","each","point","in","time",")","of","all","sets","of","all","memory","contents","(","i.e",".","a","frozenset","of","strings",")","ever","seen","in","this","execution",".","It","is","assumed","(","but","not","checked",")","that","schedule","is","a","valid","topological","sort","of","the","operations","in","this","graph",".","Args",":","schedule",":","A","list","of","integer","ids",";","the","order","to","run","operations","in",".","Returns",":","a","list","of","frozenset","of","strings",",","where","the","ith","entry","describes","the","tensors","in","memory","when","executing","operation","i","(","where","schedule","[","i","]","is","an","index","into","get_all_operation_names","(",")",")","."]
code: def compute_memory_contents_under_schedule(self, schedule):
      """The in-memory tensors present when executing each operation in schedule.
  
      Simulates running operations in the order given by a schedule. Keeps track
      of the tensors in memory at every point in time, and outputs a list (one
      entry for each point in time) of all sets of all memory contents (i.e. a
      frozenset of strings) ever seen in this execution.
  
      It is assumed (but not checked) that schedule is a valid topological sort of
      the operations in this graph.
  
      Args:
        schedule: A list of integer ids; the order to run operations in.
  
      Returns:
        a list of frozenset of strings, where the ith entry describes the tensors
        in memory when executing operation i (where schedule[i] is an index into
        get_all_operation_names()).
      """
      out_degree = self._compute_initial_out_degree()
  
      curr_memory_contents = set()
      memory_contents_for_each_operation = []
  
      for operation_id in schedule:
          operation_name = self._operations[operation_id].name
          # Allocate new memory to perform the computation at this node.
          for output_name in self.get_operation_output_names(
              operation_name
          ):
              curr_memory_contents.add(output_name)
          memory_contents_for_each_operation.append(
              frozenset(curr_memory_contents)
          )
  
          # Free any tensors which are no longer needed.
          for output_name in self.get_operation_output_names(
              operation_name
          ):
              if out_degree[output_name] == 0:
                  curr_memory_contents.remove(output_name)
          for input_name in self.get_operation_input_names(
              operation_name
          ):
              out_degree[input_name] -= 1
              if out_degree[input_name] == 0:
                  curr_memory_contents.remove(input_name)
  
      return memory_contents_for_each_operation
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import math
  import mesh_tensorflow
  import tensorflow.compat.v1
  from tensorflow.core.framework import cost_graph_pb2
label_desc: Use image node_id 19 for calling the GraphInterface obj's underlying member method code with example usage: obj.compute_memory_contents_under_schedule(schedule) and returns: memory_contents_for_each_operation