Skip to content

Shape Inference for reshape with dynamic shape #5324

@adityagoel4512

Description

@adityagoel4512

Bug Report

Currently, shape inference for Reshape intentionally does not succeed for dynamic shapes. In cases where the "shape" parameter has an inferred shape that is a value (and not a symbolic param), we can determine the output rank.

Currently, however shape inference does not succeed does not currently happen.

In the provided example copied in below, we should be able to infer a shape of (None, None) rather than just None.

def test_reshape_dynamic_shape(self) -> None:
    graph = self._make_graph(
        [("x", TensorProto.UINT8, (2, 4, 3)), ("shape", TensorProto.INT64, (2,))],
        [make_node("Reshape", ["x", "shape"], ["y"])],
        [],
    )
    self._assert_inferred(
        graph, [make_tensor_value_info("y", TensorProto.UINT8, None)]
    )

If "shape" is either None (i.e. shape cannot be inferred) or it is symbolic (e.g. ("M",)) we should still yield None as currently done.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions