def tensor_shape_to_list(tensor_type):
    """ Convert tensor shape to list
    """
    shape_list = []
    for d in tensor_type.shape.dim:
        if (d.HasField("dim_value")):
            shape_list.append(d.dim_value)  # known dimension
        elif (d.HasField("dim_param")):
            shape_list.append(d.dim_param)  # unknown dimension with symbolic name
        else:
            shape_list.append("?")  # shall not happen
    return shape_list