cVladu opened a new issue, #12052:
URL: https://github.com/apache/tvm/issues/12052

   I built a Keras LSTM network with undefined sequence length and tried to 
convert it using `relay.frontend.from_keras` with a given shape
   ### Expected behavior
   
   The network is converted
   
   ### Actual behavior
   
   `Check failed: oshape_sum == data_shape_sum (30 vs. 4500) : Input tensor 
shape(1,30) and reshaped shape(150,30) are not compatible!` raised by 
`relay.transform.InferType`
   
   ### Environment
   
   Operating system:
   Distributor ID: Ubuntu
   Description: Ubuntu 18.04.6 LTS
   Release: 18.04
   Codename: bionic
   
   TVM version: 0.9.dev0
   Steps to build the TVM were followed from: 
https://tvm.apache.org/docs/install/from_source.html -- no change to 
config.cmake file
   
   ### Steps to reproduce
   
   ```
   def test_transform_LSTM_3D_to_4D_smoke_14(known_seq_len: bool):
       if known_seq_len:
           inputs = tf.keras.layers.Input((150, 120), name="inputs")
       else:
           inputs = tf.keras.layers.Input((None, 120), name="inputs")
       lstm_out = tf.keras.layers.LSTM(30)(inputs)
       model = tf.keras.Model(inputs=inputs, outputs=lstm_out)
       model.compile()
       mod, params = relay.frontend.from_keras(model, shape={"inputs": (1, 150, 
120)})
       mod = relay.transform.InferType()(mod)
       print(mod['main'].astext())
   ```
   
   It seems like `relay.frontend.from_keras` assumes the sequence length is 1 
if not provided in `Input` layer, regardless of `shape` kwarg:
   
   ```
   #[version = "0.0.5"]
   fn (%inputs: Tensor[(1, 150, 120), float32], %v_param_3: Tensor[(120, 120), 
float32], %v_param_2: Tensor[(1, 30), float32], %v_param_4: Tensor[(120, 30), 
float32], %v_param_5: Tensor[(120), float32], %v_param_1: Tensor[(1, 30), 
float32]) {
     %0 = squeeze(%inputs, axis=[0]);
     %1 = split(%0, indices_or_sections=1);
     %2 = %1.0;
     %3 = nn.dense(%v_param_2, %v_param_4, units=120);
     %4 = nn.dense(%2, %v_param_3, units=120);
     %5 = nn.bias_add(%3, %v_param_5);
     %6 = add(%4, %5);
     %7 = split(%6, indices_or_sections=4, axis=1);
     %8 = %7.3;
     %9 = %7.1;
     %10 = sigmoid(%9);
     %11 = %7.0;
     %12 = %7.2;
     %13 = sigmoid(%11);
     %14 = tanh(%12);
     %15 = multiply(%10, %v_param_1);
     %16 = multiply(%13, %14);
     %17 = add(%15, %16);
     %18 = sigmoid(%8);
     %19 = tanh(%17);
     %20 = multiply(%18, %19);
     reshape(%20, newshape=[1, 30])
   }
   ``` \w `known_seq_length = False`
   
   If I am doing anything wrong, please let me know. Otherwise, I will try to 
automate this test and add it to the frontend tests.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to