TrainingExtensions/tensorflow/src/python/aimet_tensorflow/common/connectedgraph.py
def _create_and_link_product_if_not_exists(self, current_module_name: str, parent_module_name: str,
                                               current_tf_op: tf.Operation, parent_tf_op: tf.Operation,
                                               product_shape: tf.TensorShape, from_input: bool):
        """ Create and link new product if it does not yet exist """

        if parent_module_name + '_to_' + current_module_name in self._products:
            logger.debug("%s already exists", parent_module_name + '_to_' + current_module_name)
        else:
            product = Product(parent_module_name + '_to_' + current_module_name, product_shape)
            product.is_model_input = from_input

            # add product to self._products dictionary
            self._products[parent_module_name + '_to_' + current_module_name] = product
            logger.debug("Created new product " + parent_module_name + '_to_' + current_module_name)

            current_op = self._ops[current_module_name]
            parent_op = self._ops[parent_module_name]

            # find tf.Tensor that corresponds to this product
            connecting_tensor, _, _ = get_connecting_tensor_and_indices(parent_tf_op, current_tf_op)
            if connecting_tensor is None:
                logger.error("Could not find corresponding tensor between %s and %s",
                             parent_tf_op.name,
                             current_tf_op.name)
                assert False
            product.tensor_dict[current_op] = connecting_tensor

            # Link parent op, product, and current op
            # Fill in input, output, producer, consumer params as appropriate.
            current_op.add_input(product)
            product.producer = parent_op
            product.add_consumer(current_op)
            parent_op.output = product
            parent_op.output_shape = product_shape
 Create and link new product if it does not yet exist 
Create and link new product if it does not yet exist
Create and link new product if it does not yet exist
def _create_and_link_product_if_not_exists(self, current_module_name: str, parent_module_name: str,
                                               current_tf_op: tf.Operation, parent_tf_op: tf.Operation,
                                               product_shape: tf.TensorShape, from_input: bool):
        if parent_module_name + '_to_' + current_module_name in self._products:
            logger.debug("%s already exists", parent_module_name + '_to_' + current_module_name)
        else:
            product = Product(parent_module_name + '_to_' + current_module_name, product_shape)
            product.is_model_input = from_input
            self._products[parent_module_name + '_to_' + current_module_name] = product
            logger.debug("Created new product " + parent_module_name + '_to_' + current_module_name)
            current_op = self._ops[current_module_name]
            parent_op = self._ops[parent_module_name]
            connecting_tensor, _, _ = get_connecting_tensor_and_indices(parent_tf_op, current_tf_op)
            if connecting_tensor is None:
                logger.error("Could not find corresponding tensor between %s and %s",
                             parent_tf_op.name,
                             current_tf_op.name)
                assert False
            product.tensor_dict[current_op] = connecting_tensor
            current_op.add_input(product)
            product.producer = parent_op
            product.add_consumer(current_op)
            parent_op.output = product
            parent_op.output_shape = product_shape
def _create_and_link_product_if_not_exists ( self , current_module_name : str , parent_module_name : str , current_tf_op : tf . Operation , parent_tf_op : tf . Operation , product_shape : tf . TensorShape , from_input : bool ) : if parent_module_name + '_to_' + current_module_name in self . _products : logger . debug ( "%s already exists" , parent_module_name + '_to_' + current_module_name ) else : product = Product ( parent_module_name + '_to_' + current_module_name , product_shape ) product . is_model_input = from_input self . _products [ parent_module_name + '_to_' + current_module_name ] = product logger . debug ( "Created new product " + parent_module_name + '_to_' + current_module_name ) current_op = self . _ops [ current_module_name ] parent_op = self . _ops [ parent_module_name ] connecting_tensor , _ , _ = get_connecting_tensor_and_indices ( parent_tf_op , current_tf_op ) if connecting_tensor is None : logger . error ( "Could not find corresponding tensor between %s and %s" , parent_tf_op . name , current_tf_op . name ) assert False product . tensor_dict [ current_op ] = connecting_tensor current_op . add_input ( product ) product . producer = parent_op product . add_consumer ( current_op ) parent_op . output = product parent_op . output_shape = product_shape
Create and link new product if it does not yet exist
Create and link new product if it does not yet exist
""" Create and link new product if it does not yet exist """ # add product to self._products dictionary # find tf.Tensor that corresponds to this product # Link parent op, product, and current op # Fill in input, output, producer, consumer params as appropriate.
self
current_module_name
str
parent_module_name
str
current_tf_op
tf.Operation
parent_tf_op
tf.Operation
product_shape
tf.TensorShape
from_input
bool