TrainingExtensions/tensorflow/src/python/aimet_tensorflow/common/connectedgraph.py
def fill_op_product_graph(self):
        """
        - DFS over the graph beginning with input op given as start_op_name
        - Graph was pre-analyzed to pick out known module names
        - Creates op/product graph
        """

        visited_ops = set()
        self._process_starting_ops(self._starting_op_names)

        # op_queue is treated as a stack, containing operations to traverse.  Elements are tuples.
        # - Index 0 contains the tf operation to visit.
        # - Index 1 contains the parent operation.
        # - Index 2 contains the shape of the tensor whose output is the operation to visit.
        while self._op_queue:
            current_tf_op, parent_tf_op, product_shape = self._op_queue.pop()
            current_op_info = self._module_identifier.get_op_info(current_tf_op)
            parent_op_info = self._module_identifier.get_op_info(parent_tf_op)

            # new module, create op/product and link to parent
            if current_op_info.module_name != parent_op_info.module_name:
                self._create_op_if_not_exists(current_op_info)
                from_input = (parent_op_info.tf_op.name in self._starting_op_names)
                self._create_and_link_product_if_not_exists(current_op_info.module_name,
                                                            parent_op_info.module_name,
                                                            current_tf_op,
                                                            parent_tf_op,
                                                            product_shape,
                                                            from_input)

                # switching modules means marking previous op as output of previous module,
                # and current op as input of new current module
                self._ops[parent_op_info.module_name].output_op_node = parent_tf_op

            # add children to op_queue if not visited
            if current_tf_op.name not in visited_ops:
                num_children = self._add_children_ops_to_op_queue(current_tf_op)
                if not num_children:
                    # No children added to the queue, mark this op as the output op of the current connected graph Op
                    self._ops[current_op_info.module_name].output_op_node = current_tf_op
                visited_ops.add(current_tf_op.name)
                logger.debug("visited op: %s", current_tf_op.name)

        # Add parameter products during postprocess
        logger.debug("finished initial pass, num_products is %s", len(self._products))
        for op in self._ops.values():
            self._create_param_products(op, self._products)
            _fill_flatten_shape_if_needed(op)
            _reorder_multi_input_op_products(op)

        # Identify places where branch Ops need to be inserted
        self._branch_ops_processing()

        - DFS over the graph beginning with input op given as start_op_name
        - Graph was pre-analyzed to pick out known module names
        - Creates op/product graph
        
DFS over the graph beginning with input op given as start_op_name
Graph was pre-analyzed to pick out known module names
Creates op/product graph
DFS over the graph beginning with input op given as start_op_name Graph was pre - analyzed to pick out known module names Creates op / product graph
def fill_op_product_graph(self):
        visited_ops = set()
        self._process_starting_ops(self._starting_op_names)
        while self._op_queue:
            current_tf_op, parent_tf_op, product_shape = self._op_queue.pop()
            current_op_info = self._module_identifier.get_op_info(current_tf_op)
            parent_op_info = self._module_identifier.get_op_info(parent_tf_op)
            if current_op_info.module_name != parent_op_info.module_name:
                self._create_op_if_not_exists(current_op_info)
                from_input = (parent_op_info.tf_op.name in self._starting_op_names)
                self._create_and_link_product_if_not_exists(current_op_info.module_name,
                                                            parent_op_info.module_name,
                                                            current_tf_op,
                                                            parent_tf_op,
                                                            product_shape,
                                                            from_input)
                self._ops[parent_op_info.module_name].output_op_node = parent_tf_op
            if current_tf_op.name not in visited_ops:
                num_children = self._add_children_ops_to_op_queue(current_tf_op)
                if not num_children:
                    self._ops[current_op_info.module_name].output_op_node = current_tf_op
                visited_ops.add(current_tf_op.name)
                logger.debug("visited op: %s", current_tf_op.name)
        logger.debug("finished initial pass, num_products is %s", len(self._products))
        for op in self._ops.values():
            self._create_param_products(op, self._products)
            _fill_flatten_shape_if_needed(op)
            _reorder_multi_input_op_products(op)
        self._branch_ops_processing()
def fill_op_product_graph ( self ) : visited_ops = set ( ) self . _process_starting_ops ( self . _starting_op_names ) while self . _op_queue : current_tf_op , parent_tf_op , product_shape = self . _op_queue . pop ( ) current_op_info = self . _module_identifier . get_op_info ( current_tf_op ) parent_op_info = self . _module_identifier . get_op_info ( parent_tf_op ) if current_op_info . module_name != parent_op_info . module_name : self . _create_op_if_not_exists ( current_op_info ) from_input = ( parent_op_info . tf_op . name in self . _starting_op_names ) self . _create_and_link_product_if_not_exists ( current_op_info . module_name , parent_op_info . module_name , current_tf_op , parent_tf_op , product_shape , from_input ) self . _ops [ parent_op_info . module_name ] . output_op_node = parent_tf_op if current_tf_op . name not in visited_ops : num_children = self . _add_children_ops_to_op_queue ( current_tf_op ) if not num_children : self . _ops [ current_op_info . module_name ] . output_op_node = current_tf_op visited_ops . add ( current_tf_op . name ) logger . debug ( "visited op: %s" , current_tf_op . name ) logger . debug ( "finished initial pass, num_products is %s" , len ( self . _products ) ) for op in self . _ops . values ( ) : self . _create_param_products ( op , self . _products ) _fill_flatten_shape_if_needed ( op ) _reorder_multi_input_op_products ( op ) self . _branch_ops_processing ( )
DFS over the graph beginning with input op given as start_op_name
 Graph was pre-analyzed to pick out known module names
 Creates op/product graph
DFS over the graph beginning with input op given as start_op_name Graph was pre - analyzed to pick out known module names Creates op / product graph
"""
        - DFS over the graph beginning with input op given as start_op_name
        - Graph was pre-analyzed to pick out known module names
        - Creates op/product graph
        """ # op_queue is treated as a stack, containing operations to traverse.  Elements are tuples. # - Index 0 contains the tf operation to visit. # - Index 1 contains the parent operation. # - Index 2 contains the shape of the tensor whose output is the operation to visit. # new module, create op/product and link to parent # switching modules means marking previous op as output of previous module, # and current op as input of new current module # add children to op_queue if not visited # No children added to the queue, mark this op as the output op of the current connected graph Op # Add parameter products during postprocess # Identify places where branch Ops need to be inserted
self