I recently started to learn Relay by comparing it with NNVM. When Relay does shape inference, it requires complete input shape information from all the input tensors to succeed. For example, the following three cases would fail, while in NNVM they can run through. Is this because the add
operator is actually a broadcast_add
so that the incomplete shape info cannot be inferred, or the design of Relay has deliberately forbidden shape inference with partial input shape information? If it’s the latter one, what is the consideration behind this design?
# NNVM: no shape information provided in x1, treated as unknown shape and would be inferred from x2
# Relay: x1 is treated as a scalar
x1 = relay.var('x1')
x2 = relay.var('x2', shape=(10, 20))
y = relay.add(x1, x2)
# NNVM: zero ndim means unknown shape and will be inferred from x2
# Relay: x1 is treated as a scalar
x1 = relay.var('x1', shape=())
x2 = relay.var('x2', shape=(10, 20))
y = relay.add(x1, x2)
# NNVM: 0 dim size means unknown
# Relay: there is no such indicator
x1 = relay.var('x1', shape=(10, 0))
x2 = relay.var('x2', shape=(10, 20))
y = relay.add(x1, x2)