TrainingExtensions/tensorflow/src/python/aimet_tensorflow/common/connectedgraph.py
def _fill_flatten_shape_if_needed(op: Op):
    """
    Tensorflow flatten doesn't know its output size.  This poses a problem for Mask Propagator, so we try
    to deduce the size ourselves by looking at the input and multiplying all dimensions together.
    To ensure this is only done on flatten and not another reshape, check if the last dimension is unknown.
    """

    # If flatten op is last, it will have no output and thus no output shape
    if op.type == "Flatten" and op.output_shape:
        dims = op.output_shape.as_list()
        if dims:
            if dims[-1] is None:
                output_size = 1
                input_shape = op.inputs[0].shape.as_list()
                for dim in input_shape:
                    if dim is not None:
                        output_size *= dim
                new_output_shape = tf.TensorShape([tf.Dimension(None), tf.Dimension(output_size)])
                op.output_shape = new_output_shape
                op.output.shape = new_output_shape

    Tensorflow flatten doesn't know its output size.  This poses a problem for Mask Propagator, so we try
    to deduce the size ourselves by looking at the input and multiplying all dimensions together.
    To ensure this is only done on flatten and not another reshape, check if the last dimension is unknown.
    
Tensorflow flatten doesn't know its output size.  This poses a problem for Mask Propagator, so we try
to deduce the size ourselves by looking at the input and multiplying all dimensions together.
To ensure this is only done on flatten and not another reshape, check if the last dimension is unknown.
Tensorflow flatten doesn ' t know its output size . This poses a problem for Mask Propagator so we try to deduce the size ourselves by looking at the input and multiplying all dimensions together . To ensure this is only done on flatten and not another reshape check if the last dimension is unknown .
def _fill_flatten_shape_if_needed(op: Op):
    if op.type == "Flatten" and op.output_shape:
        dims = op.output_shape.as_list()
        if dims:
            if dims[-1] is None:
                output_size = 1
                input_shape = op.inputs[0].shape.as_list()
                for dim in input_shape:
                    if dim is not None:
                        output_size *= dim
                new_output_shape = tf.TensorShape([tf.Dimension(None), tf.Dimension(output_size)])
                op.output_shape = new_output_shape
                op.output.shape = new_output_shape
def _fill_flatten_shape_if_needed ( op : Op ) : if op . type == "Flatten" and op . output_shape : dims = op . output_shape . as_list ( ) if dims : if dims [ - 1 ] is None : output_size = 1 input_shape = op . inputs [ 0 ] . shape . as_list ( ) for dim in input_shape : if dim is not None : output_size *= dim new_output_shape = tf . TensorShape ( [ tf . Dimension ( None ) , tf . Dimension ( output_size ) ] ) op . output_shape = new_output_shape op . output . shape = new_output_shape
Tensorflow flatten doesn't know its output size.
Tensorflow flatten doesn ' t know its output size .
"""
    Tensorflow flatten doesn't know its output size.  This poses a problem for Mask Propagator, so we try
    to deduce the size ourselves by looking at the input and multiplying all dimensions together.
    To ensure this is only done on flatten and not another reshape, check if the last dimension is unknown.
    """ # If flatten op is last, it will have no output and thus no output shape
op
Op