Support tensor with shape of dimension size 0

When trying to import tensorflow ssd model into relay, there are some tensors with dimension size 0, such as shape (2, 2, 0) or (0,). In tensorflow, some cases for operators are valid but return such kind of tensors. For example, tf.slice allows out of bound begin/size, which is not allowed in tvm. Do we have a good solution for this? If we want to support 0 dimension size tensor, how much work do we need?

@tqchen @haichen @yzhliu @jroesch @yongwww

I don’t think zero dimensions logically makes sense, what is (2, 2, 0)? all of the code in the system which allocates or computes valid reshapes no longer works as the product of those dimensions becomes 0. The degenerative (0,) case also doesn’t make sense to me is it equal (1,) a tensor with no data, or a scalar?

They are all tensors with no data. However, ssd models from tf model zoo have operators generating these tensor. Actually I don’t think they are necessary in those cases and have no idea why those models are built in that way.

Another use case for 0-dim tensors is that in the concatenate for loop, it can be used as an initial value, without affecting the final output shape. Also note that 0-dim tensor is supported in the numpy syntax.

There are two parts of this problem:

  1. 0-dim: tensors with 0 dimension, and
  2. 0-size: tensors with 0 as one of its dimension.