TensorArray GlobalVar and GlobalTypeVar Confusion

Thanks @wweic for the help. I’ve just merged your changes into my branch. The newest issue comes while processing node rnn/while/Exit_2. It seems that there are two issues, and I don’t know which one is the root cause. Let me know if you have any thoughts, I’ll continue investigating :slight_smile:

Update: I’m still stumped on this. I’ve tried a handful of things that haven’t worked, and now I’m spending time trying to figure out why the while loop is malformed. Does anyone have some insight here?

In `main`: 
v0.0.4
fn (%rnn/Shape_1: Tensor[(3), int32], %Placeholder_1: Tensor[(1), int32]) {
  %9 = (
    let %while_loop-malformed-ir = fn (%loop_var0: Tensor[(1, 4), float32]) {
      %0 = strided_slice(%rnn/Shape_1, begin=[0], end=[1], strides=[1]);
      %1 = less(meta[relay.Constant][0], %0);
      %2 = max(%Placeholder_1, axis=[0]);
      %3 = maximum(meta[relay.Constant][2], %2);
      %4 = minimum(%0, %3);
      %5 = less(meta[relay.Constant][1], %4);
      %6 = logical_and(%1, %5);
      %7 = min(%6);
      if (%7) {
        free_var %while_loop
        %while_loop()
      } else {
        (%loop_var0,)
      }
    };
    %8 = full(0f, shape=[1, 4], dtype="float32");
    %while_loop(%8)
  ) unable to unify: `fn (Tensor[(1, 4), float32]) -> (Tensor[(1, 4), float32],)` and `fn () -> meta[relay.IncompleteType][0]
// meta data omitted. you can use show_meta_data=True to include meta data`; ;
  %9.2 an internal invariant was violated while typechecking your program [17:19:37] /home/jonso/dev/tvm_public_fork/tvm/src/relay/pass/type_infer.cc:76: Check failed: param->index < data->fields.size() (2 vs. 1) : 
; 
}

i think the issue here also could be because of input data structure incapability

In the latest build it gives rise to same errors as before AttributeError: <class ‘tvm.relay.expr.Call’> has no attribute type_annotation

Hi jonso. I tried your code and still have the KeyError: ‘rnn/TensorArray:1’ with the asserts removal.

My lstm code also cannot work because of this error. Do you have any clue? I am using tf 1.11 and the newest build of tvm on github. Thank you!

KeyError: 'rnn/TensorArray:1' should be fixed by line 2184 of my branch:

self._nodes[node.name + ':1'] = _expr.const(0, dtype="int32")

@AlphaXiao @OriAlpha have you had any luck running TensorFlow dynamic RNNs in TVM? If not, I may be able to spend some time on it over the next few weeks.

Thanks, jonso!

now I am having same problem you met with your lstm code.

In `main`: 
v0.0.4
fn (%rnn/Shape_1: Tensor[(3), int32], %Placeholder_1: Tensor[(1), int32]) {
  %9 = (
    let %while_loop-malformed-ir = fn (%loop_var0: Tensor[(1, 4), float32]) {
      %0 = strided_slice(%rnn/Shape_1, begin=[0], end=[1], strides=[1]);
      %1 = less(meta[relay.Constant][0], %0);
      %2 = max(%Placeholder_1, axis=[0]);
      %3 = maximum(meta[relay.Constant][2], %2);
      %4 = minimum(%0, %3);
      %5 = less(meta[relay.Constant][1], %4);
      %6 = logical_and(%1, %5);
      %7 = min(%6);
      if (%7) {
        free_var %while_loop
        %while_loop()
      } else {
        (%loop_var0,)
      }
    };
    %8 = full(0f, shape=[1, 4], dtype="float32");
    %while_loop(%8)
  ) unable to unify: `fn (Tensor[(1, 4), float32]) -> (Tensor[(1, 4), float32],)` and `fn () -> meta[relay.IncompleteType][0]
// meta data omitted. you can use show_meta_data=True to include meta data`; ;
  %9.2 an internal invariant was violated while typechecking your program [15:40:32] /f/XiaoYuwei/incubator-tvm/src/relay/pass/type_infer.cc:75: Check failed: param->index < data->fields.size() (2 vs. 1) : 
; 
}

and mine lstm test code will generate error same as oriAlpha


AttributeError: Traceback (most recent call last):
  [bt] (4) /f/incubator-tvm/build/libtvm.so(TVMFuncCall+0x61) [0x7f4faf475731]
  [bt] (3) /f/incubator-tvm/build/libtvm.so(std::_Function_handler<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*), void (*)(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::_M_invoke(std::_Any_data const&, tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&)+0x14) [0x7f4faee64324]
  [bt] (2) /f/incubator-tvm/build/libtvm.so(tvm::NodeGetAttr(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)+0x15c) [0x7f4faee5fb7c]
  [bt] (1) /f/incubator-tvm/build/libtvm.so(tvm::ReflectionVTable::GetAttr(tvm::runtime::Object*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const+0x375) [0x7f4faee5f615]
  [bt] (0) /f/incubator-tvm/build/libtvm.so(dmlc::LogMessageFatal::~LogMessageFatal()+0x32) [0x7f4faec8fa52]
  File "/f/incubator-tvm/src/node/reflection.cc", line 109
AttributeError: relay.Call object has no attributed type_annotation