How to debug and print out content of IndexExpr?

I noticed that the relay tensor shape type will be converted to int32_t after shape inference, however, if IndexExpr arithmetics is involved, the shape type will be preserved, which breaks the following example

fn (%X: Tensor[(int64(7), int64(16)), float32]) {
  %0 = reshape(%X, newshape=[7, -1, 1])
  %0
}

After shape inference, it becomes

fn (%X: Tensor[(int64(7), int64(16)), float32])
    -> Tensor[(7, int64(16), 1), float32] {
  %0 = reshape(%X, newshape=[7, -1, 1]) # ty=Tensor[(7, int64(16), 1), float32]
  %0
}

Notice the heterogenous tensor shape type for %0, which breaks the downstream compilation. I looked around the code at


but didn’t find suspicious things. And I would like to inject some debugging code to print out the content of IndexExpr in C++. Anyone knows how to do this? Thanks.

LOG(INFO) << oshape; ?

1 Like