parameters: (self, func, var, inputs)
docstring: Traverse graphs and add ops to flow.
docstring_summary: Traverse graphs and add ops to flow.
docstring_tokens: Traverse graphs and add ops to flow .
function: def expand(self, func, var, inputs):
      """Traverse graphs and add ops to flow."""
      if var not in self.vars:
        # Add new variable to flow.
        self.vars.append(var)
        v = self.flow.var(var.name, var.dtype.base_dtype.name, [])
  
        # Get data for constants and variables.
        if var.op.type in ["Const", "ConstV2"]:
          v.data = tf.contrib.util.constant_value(var)
        elif var.op.type in ["Variable", "VariableV2"]:
          if self.feed is None:
            v.data = var.eval(session=self.sess)
          else:
            v.data = self.sess.run(var, feed_dict=self.feed)
  
        # Get shape.
        if v.data is None:
          shape = var.get_shape()
          for d in shape.as_list():
            if d != None:
              v.shape.append(d)
            else:
              v.shape.append(-1)
        else:
          for d in v.data.shape:
            v.shape.append(d)
  
        if not var in inputs:
          op = var.op
          if op not in self.ops:
            # Add new operation to flow function.
            self.ops.append(op)
            o = self.flow.op(op.name)
            func.add(o)
            o.type = op.type
            for input in op.inputs:
              o.add_input(self.flow.var(input.name))
            for output in op.outputs:
              o.add_output(self.flow.var(output.name))
            for a in op.node_def.attr:
              o.add_attr(a, attr_str(op.get_attr(a)))
  
            # Traverse dependencies.
            for dep in op.inputs:
              self.expand(func, dep, inputs)
function_tokens: def expand ( self , func , var , inputs ) : if var not in self . vars : # Add new variable to flow. self . vars . append ( var ) v = self . flow . var ( var . name , var . dtype . base_dtype . name , [ ] ) # Get data for constants and variables. if var . op . type in [ "Const" , "ConstV2" ] : v . data = tf . contrib . util . constant_value ( var ) elif var . op . type in [ "Variable" , "VariableV2" ] : if self . feed is None : v . data = var . eval ( session = self . sess ) else : v . data = self . sess . run ( var , feed_dict = self . feed ) # Get shape. if v . data is None : shape = var . get_shape ( ) for d in shape . as_list ( ) : if d != None : v . shape . append ( d ) else : v . shape . append ( - 1 ) else : for d in v . data . shape : v . shape . append ( d ) if not var in inputs : op = var . op if op not in self . ops : # Add new operation to flow function. self . ops . append ( op ) o = self . flow . op ( op . name ) func . add ( o ) o . type = op . type for input in op . inputs : o . add_input ( self . flow . var ( input . name ) ) for output in op . outputs : o . add_output ( self . flow . var ( output . name ) ) for a in op . node_def . attr : o . add_attr ( a , attr_str ( op . get_attr ( a ) ) ) # Traverse dependencies. for dep in op . inputs : self . expand ( func , dep , inputs )