Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,23 @@ def _apply_non4d_model_outputs(model, *, defer_rank_conversion=False):
boundary_names = cache.graph_input_names | cache.init_names
append = []
plans = []
inputs_promotable = all(
cache.get_shape(value.name) is not None
for value in graph.input
if value.name not in cache.init_names
)
for value in graph.output:
shape = cache.get_shape(value.name)
shape: list | None = cache.get_shape(value.name)
if (
shape is None
and defer_rank_conversion
and inputs_promotable
and value.type.tensor_type.HasField("shape")
):
shape = [
dim.dim_value if dim.HasField("dim_value") else dim.dim_param or None
for dim in value.type.tensor_type.shape.dim
]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if shape is None or len(shape) >= 4 or value.name in boundary_names:
continue
producer = cache.get_producer(value.name)
Expand Down Expand Up @@ -194,7 +209,7 @@ def _apply_non4d_model_outputs(model, *, defer_rank_conversion=False):
_require_adapter_opset(model)
for value, shape, existing, axes in plans:
axes_name = None
if len(shape) > 1 or shape == [1]:
if len(shape) > 1 or shape == [1] or any(not isinstance(dim, int) for dim in shape):
axes_name = add_initializer(
graph,
cache.unique_name(value.name + "_squeeze_axes"),
Expand Down
Loading
Loading