[RELAY]Concatenate for IncompleteTypeNode


#1

How to handle this scenario

I have a conv node, followed by a concat node, but in concatRel, the tupletype is coming as IncompleteTypeNode and hence its not able to downcast. How to fix this issue
Test case to simulate this problem.

import tvm
import numpy as np
from tvm import relay
def test_conv2d_concatenate_infer_type():
        n, c, h, w = tvm.var("n"), 10, 224, 224
        x = relay.var("x", relay.ty.TensorType((n, c, h, w), "float32"))
        w = relay.var("w")
        conv = relay.nn.conv2d(x, w,
                            kernel_size=(3, 3),
                            padding=(1, 1),
                            channels=2)
        y = relay.var("y", shape=(n, 2, 224, 224))

        z = relay.concatenate((y, conv), axis=0)
        zz = relay.ir_pass.infer_type(z)
        print(zz.checked_type)

test_conv2d_concatenate_infer_type()

Output

[12:26:20] /home/siju/D/work/relay2/tvm/src/relay/op/tensor/transform.cc:155: TensorType([n, 2, 224, 224], float32)
[12:26:20] /home/siju/D/work/relay2/tvm/src/relay/op/tensor/transform.cc:155: IncompleteTypeNode(0, 0x1e773c0)

tvm._ffi.base.TVMError: [12:26:20] /home/siju/D/work/relay2/tvm/3rdparty/HalideIR/src/tvm/node/node.h:260: Check failed: ref->template is_type<typename SubRef::ContainerType>() || ref->template derived_from<typename SubRef::ContainerType>() Downcast from relay.IncompleteType to relay.TensorType failed.

Stack trace returned 10 entries:
[bt] (0) /home/siju/.local/lib/python3.6/site-packages/tvm-0.5.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(dmlc::StackTrace[abi:cxx11]()+0x1b0) [0x7fe11b639590]
[bt] (1) /home/siju/.local/lib/python3.6/site-packages/tvm-0.5.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x39) [0x7fe11b63a439]
[bt] (2) /home/siju/.local/lib/python3.6/site-packages/tvm-0.5.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::TensorType tvm::Downcast<tvm::relay::TensorType, tvm::relay::Type>(tvm::relay::Type)+0x21a) [0x7fe11b9bc8ba]
[bt] (3) /home/siju/.local/lib/python3.6/site-packages/tvm-0.5.dev0-py3.6-linux-x86_64.egg/tvm/libtvm.so(tvm::relay::ConcatenateRel(tvm::Array<tvm::relay::Type, void> const&, int, tvm::Attrs const&, tvm::relay::TypeReporter const&)+0x42b) [0x7fe11b9b1dfb]

@junrushao1994 @MarisaKirisame @jroesch @tqchen please help to know how to fix this issue.

Thanks


#2

This should be fixed by https://github.com/dmlc/tvm/pull/2031