Bidirectional LSTM

TRT 8.0

from keras.layers.recurrent import LSTM  
x = Bidirectional(LSTM(32, return_sequences=True, recurrent_activation='hard_sigmoid'))(x)
x = LSTM(32, return_sequences=False, recurrent_activation='hard_sigmoid')(x)

It has the below error when we do tensorrt onnx parser.
“The parser does not currently support cases where activations for the reverse pass of the LSTM do not match the forward pass.”

trt 8.0 onnx supports “hard_sigmoid” activation,-> NvInfer.h → ActivationType kHARD_SIGMOID = 9
but dose trt onnx parser support bidirectional lstm with hard_sigmoid activation ?

builtin_op_importers.cpp line2339: “The parser does not currently support cases where activations for the reverse pass of the LSTM do not match the forward pass.”

The below bidirectional lstm with sigmoid activation has no problem

x = Bidirectional(LSTM(32, return_sequences=True))(x)
x = LSTM(32, return_sequences=False)(x)

Thanks

Hi,
Request you to share the ONNX model and the script if not shared already so that we can assist you better.
Alongside you can try few things:
https://docs.nvidia.com/deeplearning/tensorrt/quick-start-guide/index.html#onnx-export

  1. validating your model with the below snippet

check_model.py

import sys
import onnx
filename = yourONNXmodel
model = onnx.load(filename)
onnx.checker.check_model(model).
2) Try running your model with trtexec command.
https://github.com/NVIDIA/TensorRT/tree/master/samples/opensource/trtexec
In case you are still facing issue, request you to share the trtexec “”–verbose"" log for further debugging
Thanks!

LSTM_model1.onnx (273.4 KB)

$ trtexec --onnx=LSTM_model1.onnx

[08/12/2021-07:39:46] [E] [TRT] ModelImporter.cpp:725: ERROR: builtin_op_importers.cpp:2339 In function importLSTM:
[8] Assertion failed: std::equal(activationAlphas.begin(), activationAlphas.begin() + NUM_ACTIVATIONS, activationAlphas.begin() + NUM_ACTIVATIONS) && “The parser does not currently support cases where activations for the reverse pass of the LSTM do not match the forward pass.”
[08/12/2021-07:39:46] [E] Failed to parse onnx file

@ding9801,

Could you please share us more details for better help.

Environment

TensorRT Version :
GPU Type :
Nvidia Driver Version :
CUDA Version :
CUDNN Version :
Operating System + Version :
Python Version (if applicable) :
TensorFlow/Keras Version (if applicable) :
PyTorch Version (if applicable) :
Baremetal or Container (if container which image + tag) :

Thank you.

@spolisetty
TRT version : 8.0
GPU Type : Any
Nvidia Driver Version : Any
CUDA Version : Any
CUDNN Version : Any
Operating System + Version : Any
Python Version (if applicable) : Any
TensorFlow/Keras Version (if applicable) : Any
PyTorch Version (if applicable) : Any
Baremetal or Container (if container which image + tag) : Any

Hi,

This is expected behavior. Currently we support bidirectional lstm, but we do not support activations for the reverse pass of the LSTM do not match the forward pass.

Thank you.