/****************************************************************************
*
*    Copyright (c) 2020 Vivante Corporation
*
*    Permission is hereby granted, free of charge, to any person obtaining a
*    copy of this software and associated documentation files (the "Software"),
*    to deal in the Software without restriction, including without limitation
*    the rights to use, copy, modify, merge, publish, distribute, sublicense,
*    and/or sell copies of the Software, and to permit persons to whom the
*    Software is furnished to do so, subject to the following conditions:
*
*    The above copyright notice and this permission notice shall be included in
*    all copies or substantial portions of the Software.
*
*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
*    DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/


#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "vsi_nn_types.h"
#include "vsi_nn_tensor.h"
#include "vsi_nn_graph.h"
#include "vsi_nn_log.h"
#include "vsi_nn_error.h"
#include "vsi_nn_prv.h"
#include "vsi_nn_tensor_util.h"
#include "utils/vsi_nn_util.h"
#include "kernel/vsi_nn_kernel.h"
#include "libnnext/vx_lib_nnext.h"

__BEGIN_DECLS

/*
 * Define kernel meta.
 */
typedef enum _LSTMUNIT_nn_activation_type_e
{
    SIGMOID = VSI_NN_ACT_SIGMOID,
    HARD_SIGMOID = VSI_NN_ACT_HARD_SIGMOID,
}LSTMUNIT_nn_activation_type_e;

typedef enum _LSTMUNIT_nn_activation_e
{
    CLP_E = 0x1C,
    LP_E  = 0x14,
    CL_E  = 0x18,
    L_E   = 0x10,
    BP_E  = 0x06,
    B_E   = 0x02,
    CBP_E = 0x0E,
    CB_E  = 0x0A,
    SP_E  = 0x04,
    S_E   = 0x00,
    CSP_E = 0x0C,
    CS_E  = 0x08,
}LSTMUNIT_nn_activation_e;


#define LSTMUNIT_ACTIVATION_HASH_KEY(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, \
_input_type, _output_type, _cell_type, _rec_act) \
((_is_ln << 31) | (_is_cifg << 30) | (_is_proj << 29) | (_is_hybrid << 28) | (_is_peephole << 27) \
| (_input_type << 23) | (_output_type << 19) | (_cell_type << 15) | (_rec_act << 10))

#define LSTMUNIT_ACTIVATION_SOURCE_NAME(_ln_cifg_proj_hybrid_, _input_type) \
    "lstmunit_activation_"#_ln_cifg_proj_hybrid_"_"#_input_type

#define GEN_LSTMUNIT_STRUCT_ITEMS(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, _input_type, _output_type, \
        _cell_type, _rec_act, _ln_cifg_proj_hybrid_) \
    { LSTMUNIT_ACTIVATION_HASH_KEY(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, \
    _input_type, _output_type, _cell_type, _rec_act), \
    CVIVANTE_NAMESPACE(\
    "cl.lstmunit_activation_"#_ln_cifg_proj_hybrid_"_"#_input_type"to"#_output_type"_"#_cell_type"_"#_rec_act), \
    LSTMUNIT_ACTIVATION_SOURCE_NAME(_ln_cifg_proj_hybrid_, _input_type) },

typedef struct
{
    uint32_t key;
    char * function_name;
    const char * source_name;
} _kernel_map_type;

static const _kernel_map_type _lstmunit_activation_kernel_map[] =
{
        /* layer norm + cifg + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F32, F32, F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F32, F32, F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, U8 , U8 , F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, U8 , U8 , F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F32, U8 , F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F32, U8 , F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, U8 , F32, F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, U8 , F32, F32, HARD_SIGMOID, CLP)
        /* layer norm + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F32, F32, F32, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F32, F32, F32, HARD_SIGMOID, LP)
        /* layer norm + cifg */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F32, F32, F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F32, F32, F32, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, U8 , U8 , F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, U8 , U8 , F32, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F32, U8 , F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F32, U8 , F32, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, U8 , F32, F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, U8 , F32, F32, HARD_SIGMOID, CL)
        /* layer norm */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F32, F32, F32, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F32, F32, F32, HARD_SIGMOID, L)
        /* hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F32, F32, F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F32, F32, F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8 , U8 , F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8 , U8 , F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F32, U8 , F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F32, U8 , F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8 , F32, F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8 , F32, F32, HARD_SIGMOID, BP)
        /* hybrid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F32, F32, F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F32, F32, F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8 , U8 , F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8 , U8 , F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F32, U8 , F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F32, U8 , F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8 , F32, F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8 , F32, F32, HARD_SIGMOID, B)
        /* cifg + hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F32, F32, F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F32, F32, F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8 , U8 , F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8 , U8 , F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F32, U8 , F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F32, U8 , F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8 , F32, F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8 , F32, F32, HARD_SIGMOID, CBP)
        /* cifg + hybrid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F32, F32, F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F32, F32, F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8 , U8 , F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8 , U8 , F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F32, U8 , F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F32, U8 , F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8 , F32, F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8 , F32, F32, HARD_SIGMOID, CB)
        /* standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F32, F32, F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F32, F32, F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8 , U8 , F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8 , U8 , F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F32, U8 , F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F32, U8 , F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8 , F32, F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8 , F32, F32, HARD_SIGMOID, SP)
        /* standard */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F32, F32, F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F32, F32, F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8 , U8 , F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8 , U8 , F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F32, U8 , F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F32, U8 , F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8 , F32, F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8 , F32, F32, HARD_SIGMOID, S)
        /* cifg + standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F32, F32, F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F32, F32, F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8 , U8 , F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8 , U8 , F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F32, U8 , F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F32, U8 , F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8 , F32, F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8 , F32, F32, HARD_SIGMOID, CSP)
        /* cifg + standard */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F32, F32, F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F32, F32, F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8 , U8 , F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8 , U8 , F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F32, U8 , F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F32, U8 , F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8 , F32, F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8 , F32, F32, HARD_SIGMOID, CS)
};


typedef enum _lstmunit_cifg_ln_proj_e
{
    CLP_INPUT_FC_F,
    CLP_INPUT_FC_C,
    CLP_INPUT_FC_O,
    CLP_CSTATE_IN,
    CLP_BIASES_F,
    CLP_BIASES_C,
    CLP_BIASES_O,
    CLP_LN_WF,
    CLP_LN_WC,
    CLP_LN_WO,
    CLP_OUTPUT,
    CLP_CSTATE_OUT,
    CLP_PARAM
} lstmunit_cifg_ln_proj_e;

static vx_param_description_t vxLSTMUNIT_CLP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CLP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CLP_Param )
#define _LSTMUNIT_ACTIVATION_CLP_IN_OUT_NUM  12

typedef enum _lstmunit_cifg_ln_e
{
    CL_INPUT_FC_F,
    CL_INPUT_FC_C,
    CL_INPUT_FC_O,
    CL_CSTATE_IN,
    CL_BIASES_F,
    CL_BIASES_C,
    CL_BIASES_O,
    CL_LN_WF,
    CL_LN_WC,
    CL_LN_WO,
    CL_OUTPUT,
    CL_CSTATE_OUT,
    CL_HSTATE_OUT,
    CL_LSTMUNIT_PARAM,
} lstmunit_cifg_ln_e;

static vx_param_description_t vxLSTMUNIT_CL_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CL_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CL_Param )
#define _LSTMUNIT_ACTIVATION_CL_IN_OUT_NUM  13

typedef enum _lstmunit_ln_proj_e
{
    LP_INPUT_FC_I,
    LP_INPUT_FC_F,
    LP_INPUT_FC_C,
    LP_INPUT_FC_O,
    LP_CSTATE_IN,
    LP_BIASES_I,
    LP_BIASES_F,
    LP_BIASES_C,
    LP_BIASES_O,
    LP_LN_WI,
    LP_LN_WF,
    LP_LN_WC,
    LP_LN_WO,
    LP_OUTPUT,
    LP_CSTATE_OUT,
    LP_PARAM
} lstmunit_ln_proj_e;

static vx_param_description_t vxLSTMUNIT_LP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_LP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_LP_Param )
#define _LSTMUNIT_ACTIVATION_LP_IN_OUT_NUM  15

typedef enum _lstmunit_ln_e
{
    L_INPUT_FC_I,
    L_INPUT_FC_F,
    L_INPUT_FC_C,
    L_INPUT_FC_O,
    L_CSTATE_IN,
    L_BIASES_I,
    L_BIASES_F,
    L_BIASES_C,
    L_BIASES_O,
    L_LN_WI,
    L_LN_WF,
    L_LN_WC,
    L_LN_WO,
    L_OUTPUT,
    L_CSTATE_OUT,
    L_HSTATE_OUT,
    L_LSTMUNIT_PARAM,
} lstmunit_ln_e;

static vx_param_description_t vxLSTMUNIT_L_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_L_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_L_Param )
#define _LSTMUNIT_ACTIVATION_L_IN_OUT_NUM  16

typedef enum _lstmunit_hybrid_proj_e
{
    BP_INPUT_FC_I,
    BP_INPUT_FC_F,
    BP_INPUT_FC_C,
    BP_INPUT_FC_O,
    BP_CSTATE_IN,
    BP_HSTATE_FC_I,
    BP_HSTATE_FC_F,
    BP_HSTATE_FC_C,
    BP_HSTATE_FC_O,
    BP_BIASES_I,
    BP_BIASES_F,
    BP_BIASES_C,
    BP_BIASES_O,
    BP_OUTPUT,
    BP_CSTATE_OUT,
    BP_PARAM
} lstmunit_hybrid_proj_e;

static vx_param_description_t vxLSTMUNIT_BP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_BP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_BP_Param )
#define _LSTMUNIT_ACTIVATION_BP_IN_OUT_NUM  15

typedef enum _lstmunit_hybrid_e
{
    B_INPUT_FC_I,
    B_INPUT_FC_F,
    B_INPUT_FC_C,
    B_INPUT_FC_O,
    B_CSTATE_IN,
    B_HSTATE_FC_I,
    B_HSTATE_FC_F,
    B_HSTATE_FC_C,
    B_HSTATE_FC_O,
    B_BIASES_I,
    B_BIASES_F,
    B_BIASES_C,
    B_BIASES_O,
    B_OUTPUT,
    B_CSTATE_OUT,
    B_HSTATE_OUT,
    B_LSTMUNIT_PARAM,
} lstmunit_hybrid_e;

static vx_param_description_t vxLSTMUNIT_B_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_B_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_B_Param )
#define _LSTMUNIT_ACTIVATION_B_IN_OUT_NUM  16

typedef enum _lstmunit_cifg_hybrid_proj_e
{
    CBP_INPUT_FC_F,
    CBP_INPUT_FC_C,
    CBP_INPUT_FC_O,
    CBP_CSTATE_IN,
    CBP_HSTATE_FC_F,
    CBP_HSTATE_FC_C,
    CBP_HSTATE_FC_O,
    CBP_BIASES_F,
    CBP_BIASES_C,
    CBP_BIASES_O,
    CBP_OUTPUT,
    CBP_CSTATE_OUT,
    CBP_PARAM
} lstmunit_cifg_hybrid_proj_e;

static vx_param_description_t vxLSTMUNIT_CBP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CBP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CBP_Param )
#define _LSTMUNIT_ACTIVATION_CBP_IN_OUT_NUM  12

typedef enum _lstmunit_cifg_hybrid_e
{
    CB_INPUT_FC_F,
    CB_INPUT_FC_C,
    CB_INPUT_FC_O,
    CB_CSTATE_IN,
    CB_HSTATE_FC_F,
    CB_HSTATE_FC_C,
    CB_HSTATE_FC_O,
    CB_BIASES_F,
    CB_BIASES_C,
    CB_BIASES_O,
    CB_OUTPUT,
    CB_CSTATE_OUT,
    CB_HSTATE_OUT,
    CB_LSTMUNIT_PARAM,
} lstmunit_cifg_hybrid_e;

static vx_param_description_t vxLSTMUNIT_CB_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CB_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CB_Param )
#define _LSTMUNIT_ACTIVATION_CB_IN_OUT_NUM  13

typedef enum _lstmunit_standard_proj_e
{
    SP_INPUT_FC_I,
    SP_INPUT_FC_F,
    SP_INPUT_FC_C,
    SP_INPUT_FC_O,
    SP_CSTATE_IN,
    SP_HSTATE_FC_I,
    SP_HSTATE_FC_F,
    SP_HSTATE_FC_C,
    SP_HSTATE_FC_O,
    SP_OUTPUT,
    SP_CSTATE_OUT,
    SP_PARAM
} lstmunit_standard_proj_e;

static vx_param_description_t vxLSTMUNIT_SP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_SP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_SP_Param )
#define _LSTMUNIT_ACTIVATION_SP_IN_OUT_NUM  11

typedef enum _lstmunit_standard_e
{
    S_INPUT_FC_I,
    S_INPUT_FC_F,
    S_INPUT_FC_C,
    S_INPUT_FC_O,
    S_CSTATE_IN,
    S_HSTATE_FC_I,
    S_HSTATE_FC_F,
    S_HSTATE_FC_C,
    S_HSTATE_FC_O,
    S_OUTPUT,
    S_CSTATE_OUT,
    S_HSTATE_OUT,
    S_LSTMUNIT_PARAM,
} lstmunit_standard_e;

static vx_param_description_t vxLSTMUNIT_S_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_S_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_S_Param )
#define _LSTMUNIT_ACTIVATION_S_IN_OUT_NUM  12

typedef enum _lstmunit_cifg_standard_proj_e
{
    CSP_INPUT_FC_F,
    CSP_INPUT_FC_C,
    CSP_INPUT_FC_O,
    CSP_CSTATE_IN,
    CSP_HSTATE_FC_F,
    CSP_HSTATE_FC_C,
    CSP_HSTATE_FC_O,
    CSP_OUTPUT,
    CSP_CSTATE_OUT,
    CSP_PARAM
} lstmunit_cifg_standard_proj_e;

static vx_param_description_t vxLSTMUNIT_CSP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CSP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CSP_Param )
#define _LSTMUNIT_ACTIVATION_CSP_IN_OUT_NUM  9

typedef enum _lstmunit_cifg_standard_e
{
    CS_INPUT_FC_F,
    CS_INPUT_FC_C,
    CS_INPUT_FC_O,
    CS_CSTATE_IN,
    CS_HSTATE_FC_F,
    CS_HSTATE_FC_C,
    CS_HSTATE_FC_O,
    CS_OUTPUT,
    CS_CSTATE_OUT,
    CS_HSTATE_OUT,
    CS_LSTMUNIT_PARAM,
} lstmunit_cifg_standard_e;

static vx_param_description_t vxLSTMUNIT_CS_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CS_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CS_Param )
#define _LSTMUNIT_ACTIVATION_CS_IN_OUT_NUM  10

#define _LSTMUINT_PARAM_NUM 23

#define _LSTMUNIT_ACTIVATION_MAX_PARAM_NUM (LSTMUNIT_ACT_PARAM_COUT + _LSTMUINT_PARAM_NUM)



DEF_KERNEL_INITIALIZER(_lstmunit_activation_CL_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    vsi_nn_kernel_tensor_attr_t* output_attr;

    output = (vsi_nn_kernel_tensor_t)param[CL_OUTPUT];

    output_attr = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( output_attr, "Create tensor attr buffer fail.", final );

    gpu_param.global_scale[0]  = 1;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((output_attr->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (output_attr->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:

    if (output_attr)
    {
        vsi_nn_kernel_tensor_attr_release( &output_attr );
    }

    return status;
} /* _lstmunit_activation_initializer() */

DEF_KERNEL_INITIALIZER(_lstmunit_activation_CB_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    vsi_nn_kernel_tensor_attr_t* output_attr;

    output = (vsi_nn_kernel_tensor_t)param[CB_OUTPUT];
    output_attr = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( output_attr, "Create tensor attr buffer fail.", final );

    gpu_param.global_scale[0]  = 1;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((output_attr->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (output_attr->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:

    if (output_attr)
    {
        vsi_nn_kernel_tensor_attr_release( &output_attr );
    }

    return status;
} /* _lstmunit_activation_initializer() */

/*
 * Kernel initializer
 */
DEF_KERNEL_INITIALIZER(_lstmunit_activation_CS_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    vsi_nn_kernel_tensor_attr_t* output_attr;

    output = (vsi_nn_kernel_tensor_t)param[CS_OUTPUT];

    output_attr = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( output_attr, "Create tensor attr buffer fail.", final );

    gpu_param.global_scale[0]  = 1;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((output_attr->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (output_attr->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:

    if (output_attr)
    {
        vsi_nn_kernel_tensor_attr_release( &output_attr );
    }

    return status;
} /* _lstmunit_activation_initializer() */


/*
 * Kernel initializer
 */
DEF_KERNEL_INITIALIZER(_lstmunit_activation_L_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    vsi_nn_kernel_tensor_attr_t* output_attr;

    output = (vsi_nn_kernel_tensor_t)param[L_OUTPUT];

    output_attr = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( output_attr, "Create tensor attr buffer fail.", final );

    gpu_param.global_scale[0]  = 1;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((output_attr->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (output_attr->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:

    if (output_attr)
    {
        vsi_nn_kernel_tensor_attr_release( &output_attr );
    }

    return status;
} /* _lstmunit_activation_initializer() */

/*
 * Kernel initializer
 */
DEF_KERNEL_INITIALIZER(_lstmunit_activation_B_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    vsi_nn_kernel_tensor_attr_t* output_attr;

    output = (vsi_nn_kernel_tensor_t)param[B_OUTPUT];

    output_attr = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( output_attr, "Create tensor attr buffer fail.", final );

    gpu_param.global_scale[0]  = 1;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((output_attr->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (output_attr->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:

    if (output_attr)
    {
        vsi_nn_kernel_tensor_attr_release( &output_attr );
    }

    return status;
} /* _lstmunit_activation_initializer() */


/*
 * Kernel initializer
 */
DEF_KERNEL_INITIALIZER(_lstmunit_activation_S_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    vsi_nn_kernel_tensor_attr_t* output_attr;

    output = (vsi_nn_kernel_tensor_t)param[S_OUTPUT];

    output_attr = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( output_attr, "Create tensor attr buffer fail.", final );

    gpu_param.global_scale[0]  = 1;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((output_attr->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (output_attr->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:

    if (output_attr)
    {
        vsi_nn_kernel_tensor_attr_release( &output_attr );
    }

    return status;
} /* _lstmunit_activation_initializer() */


static size_t get_param_num(LSTMUNIT_nn_activation_e lstm_activation)
{
    size_t   lstm_activation_param_num = LSTMUNIT_ACT_PARAM_COUT;

    switch (lstm_activation)
    {
        case CLP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CLP_PARAM_NUM;
        break;
        case LP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_LP_PARAM_NUM;
        break;
        case CL_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CL_PARAM_NUM;
        break;
        case L_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_L_PARAM_NUM;
        break;
        case BP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_BP_PARAM_NUM;
        break;
        case B_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_B_PARAM_NUM;
        break;
        case CBP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CBP_PARAM_NUM;
        break;
        case CB_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CB_PARAM_NUM;
        break;
        case SP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_SP_PARAM_NUM;
        break;
        case S_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_S_PARAM_NUM;
        break;
        case CSP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CSP_PARAM_NUM;
        break;
        case CS_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CS_PARAM_NUM;
        break;
        default:
        break;
    }
    return lstm_activation_param_num;
}

static size_t get_in_out_num(LSTMUNIT_nn_activation_e lstm_activation)
{
    size_t   lstm_activation_in_out_num = LSTMUNIT_ACT_PARAM_COUT;

    switch (lstm_activation)
    {
        case CLP_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_CLP_IN_OUT_NUM;
        break;
        case LP_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_LP_IN_OUT_NUM;
        break;
        case CL_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_CL_IN_OUT_NUM;
        break;
        case L_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_L_IN_OUT_NUM;
        break;
        case BP_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_BP_IN_OUT_NUM;
        break;
        case B_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_B_IN_OUT_NUM;
        break;
        case CBP_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_CBP_IN_OUT_NUM;
        break;
        case CB_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_CB_IN_OUT_NUM;
        break;
        case SP_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_SP_IN_OUT_NUM;
        break;
        case S_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_S_IN_OUT_NUM;
        break;
        case CSP_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_CSP_IN_OUT_NUM;
        break;
        case CS_E:
            lstm_activation_in_out_num = _LSTMUNIT_ACTIVATION_CS_IN_OUT_NUM;
        break;
        default:
        break;
    }
    return lstm_activation_in_out_num;
}

static void set_vx_param_description_t(LSTMUNIT_nn_activation_e lstm_activation, vx_param_description_t ** param_def)
{
    switch (lstm_activation)
    {
        case CLP_E:
            *param_def = vxLSTMUNIT_CLP_Param;
        break;
        case LP_E:
            *param_def = vxLSTMUNIT_LP_Param;
        break;
        case CL_E:
            *param_def = vxLSTMUNIT_CL_Param;
        break;
        case L_E:
            *param_def = vxLSTMUNIT_L_Param;
        break;
        case BP_E:
            *param_def = vxLSTMUNIT_BP_Param;
        break;
        case B_E:
            *param_def = vxLSTMUNIT_B_Param;
        break;
        case CBP_E:
            *param_def = vxLSTMUNIT_CBP_Param;
        break;
        case CB_E:
            *param_def = vxLSTMUNIT_CB_Param;
        break;
        case SP_E:
            *param_def = vxLSTMUNIT_SP_Param;
        break;
        case S_E:
            *param_def = vxLSTMUNIT_S_Param;
        break;
        case CSP_E:
            *param_def = vxLSTMUNIT_CSP_Param;
        break;
        case CS_E:
            *param_def = vxLSTMUNIT_CS_Param;
        break;
        default:
        break;
    }
}


/*
 * Query kernel
 */
static vsi_status _query_kernel
    (
    vsi_nn_kernel_t * kernel,
    vsi_nn_tensor_t * const * const inputs,
    vsi_nn_tensor_t * const * const outputs,
    int32_t  _is_ln,
    int32_t  _is_cifg,
    int32_t  _is_proj,
    int32_t  _is_hybrid,
    int32_t  _is_peephole,
    int32_t  recurrent_activation,
    vsi_bool *is_u8_type,
    LSTMUNIT_nn_activation_e lstm_activation
    )
{
    vsi_status status = VSI_FAILURE;
    vsi_nn_kernel_dtype_e in_dtype;
    vsi_nn_kernel_dtype_e cell_dtype;
    vsi_nn_kernel_dtype_e out_dtype;
    const _kernel_map_type * kernel_map = _lstmunit_activation_kernel_map;
    size_t kernel_map_size              = _cnt_of_array( _lstmunit_activation_kernel_map );
    vx_param_description_t * param_def  = NULL;
    size_t param_def_size               = _LSTMUNIT_ACTIVATION_MAX_PARAM_NUM;
    vx_kernel_initialize_f  initializer = NULL;
    uint32_t key;
    uint32_t i;

    set_vx_param_description_t( lstm_activation, &param_def );

    if (NULL == param_def)
    {
        status = VSI_FAILURE;
        return status;
    }

    if (_is_cifg)
    {
        if (_is_ln)
            initializer = _lstmunit_activation_CL_initializer;
        else if (_is_hybrid)
            initializer = _lstmunit_activation_CB_initializer;
        else
            initializer = _lstmunit_activation_CS_initializer;
    }
    else
    {
        if (_is_ln)
            initializer = _lstmunit_activation_L_initializer;
        else if (_is_hybrid)
            initializer = _lstmunit_activation_B_initializer;
        else
            initializer = _lstmunit_activation_S_initializer;
    }

    param_def_size = get_param_num(lstm_activation);
    in_dtype   = vsi_nn_kernel_map_dtype( inputs[LSTMUNIT_ACT_INPUT_FC_F]->attr.dtype.vx_type );
    cell_dtype = vsi_nn_kernel_map_dtype( inputs[LSTMUNIT_ACT_CSTATE_IN]->attr.dtype.vx_type );
    out_dtype  = vsi_nn_kernel_map_dtype( outputs[0]->attr.dtype.vx_type );

    if (F16 == in_dtype)
    {
        in_dtype = F32;
    }

    if (F16 == cell_dtype)
    {
        cell_dtype = F32;
    }

    if (F16 == out_dtype)
    {
        out_dtype = F32;
    }

    if ((U8 == in_dtype) || (U8 == out_dtype))
    {
        *is_u8_type = TRUE;
    }
    else
    {
        *is_u8_type = FALSE;
    }

    key = LSTMUNIT_ACTIVATION_HASH_KEY(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, \
    in_dtype, out_dtype, cell_dtype, recurrent_activation);

    for( i = 0; i < kernel_map_size; i ++ )
    {
        if( kernel_map[i].key == key )
        {
            break;
        }
    }

    if( i < kernel_map_size )
    {
        snprintf( kernel->info.name, VX_MAX_KERNEL_NAME, "%s",  kernel_map[i].function_name );
        kernel->info.parameters  = param_def;
        kernel->info.numParams   = (uint32_t)param_def_size;
        kernel->info.initialize  = initializer;
        // Register code source
        vsi_nn_kernel_add_source( kernel, VSI_NN_GPU_SOURCE_FMT_CODE, 1,
                kernel_map[i].source_name );
        // Register binary source
        vsi_nn_kernel_add_source( kernel, VSI_NN_GPU_SOURCE_FMT_EXECUTABLE, 1,
                kernel_map[i].source_name );
        status = VSI_SUCCESS;
    }

    return status;
} /* _query_kernel() */


static vsi_nn_kernel_node_t _setup
    (
    vsi_nn_graph_t              * graph,
    vsi_nn_tensor_t            ** inputs,
    size_t                        input_num,
    vsi_nn_tensor_t            ** outputs,
    size_t                        output_num,
    const vsi_nn_kernel_param_t * params,
    vsi_nn_kernel_t             * kernel
    )
{
    vsi_status status = VSI_FAILURE;
    vsi_nn_kernel_node_param_t node_params[_LSTMUNIT_ACTIVATION_MAX_PARAM_NUM] = {NULL};
    vsi_nn_kernel_node_t node = NULL;
    vsi_nn_tensor_t* in_tensor[LSTMUNIT_ACT_INPUTS_COUNT] = {NULL};
    vsi_nn_tensor_t* out_tensor[LSTMUNIT_ACT_OUTUTS_COUNT] = {NULL};
    size_t   input_cnt  = 0;
    size_t   output_cnt = 0;
    int32_t  _is_ln= 0;
    int32_t  _is_cifg= 0;
    int32_t  _is_proj= 0;
    int32_t  _is_hybrid= 0;
    int32_t  _is_peephole= 0;
    int32_t  recurrent_activation;
    float    cell_clip;
    float    forget_bias;
    float    logE                   = (vx_float32)(log10(exp(1.0f)) / log10(2.0f));
    float    twoLogE                = 2 * logE;
    uint32_t uint_min               = 0xFBFFFFFF;
    uint32_t uint_max               = 0x7BFFFFFF;
    float    float_min              = *(vx_float32 *)&uint_min;
    float    float_max              = *(vx_float32 *)&uint_max;
    float    scale_val[9]           = {1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f};
    float    tail_val[9]            = {0, 0, 0, 0, 0, 0, 0, 0, 0};
    vsi_bool is_u8_type = FALSE;
    LSTMUNIT_nn_activation_e lstm_activation;
    size_t   lstm_activation_param_num = _LSTMUNIT_ACTIVATION_MAX_PARAM_NUM;
    size_t   lstm_activation_in_out_num = 0;
    uint32_t i;

    _is_ln               = vsi_nn_kernel_param_get_int32( params, "_is_ln" );
    _is_cifg             = vsi_nn_kernel_param_get_int32( params, "_is_cifg" );
    _is_proj             = vsi_nn_kernel_param_get_int32( params, "_is_proj" );
    _is_hybrid           = vsi_nn_kernel_param_get_int32( params, "_is_hybrid" );
    _is_peephole         = vsi_nn_kernel_param_get_int32( params, "_is_peephole" );
    recurrent_activation = vsi_nn_kernel_param_get_int32( params, "recurrent_activation" );
    cell_clip            = vsi_nn_kernel_param_get_float32(params, "cell_clip");
    forget_bias          = vsi_nn_kernel_param_get_float32(params, "forget_bias");

    lstm_activation      = (LSTMUNIT_nn_activation_e)((_is_ln << 4) |\
    (_is_cifg << 3) | (_is_proj << 2) | (_is_hybrid << 1) | (_is_peephole));
    status = _query_kernel( kernel, inputs, outputs, _is_ln, _is_cifg,\
    _is_proj, _is_hybrid, _is_peephole, recurrent_activation, &is_u8_type, lstm_activation);

    if (cell_clip > 0)
    {
        float_max = cell_clip;
        float_min = -cell_clip;
    }


    if (inputs[LSTMUNIT_ACT_INPUT_FC_I] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_INPUT_FC_I]->attr.dtype.vx_type)
    {
        scale_val[0] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_INPUT_FC_I]);
        tail_val[0]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_INPUT_FC_I]) * scale_val[0];
    }

    if (inputs[LSTMUNIT_ACT_INPUT_FC_F] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_INPUT_FC_F]->attr.dtype.vx_type)
    {
        scale_val[1] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_INPUT_FC_F]);
        tail_val[1]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_INPUT_FC_F]) * scale_val[1];
    }

    if (inputs[LSTMUNIT_ACT_INPUT_FC_C] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_INPUT_FC_C]->attr.dtype.vx_type)
    {
        scale_val[2] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_INPUT_FC_C]);
        tail_val[2]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_INPUT_FC_C]) * scale_val[2];
    }

    if (inputs[LSTMUNIT_ACT_INPUT_FC_O] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_INPUT_FC_O]->attr.dtype.vx_type)
    {
        scale_val[3] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_INPUT_FC_O]);
        tail_val[3]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_INPUT_FC_O]) * scale_val[3];
    }


    if (inputs[LSTMUNIT_ACT_HSTATE_FC_I] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_HSTATE_FC_I]->attr.dtype.vx_type)
    {
        scale_val[4] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_HSTATE_FC_I]);
        tail_val[4]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_HSTATE_FC_I]) * scale_val[4];
    }

    if (inputs[LSTMUNIT_ACT_HSTATE_FC_F] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_HSTATE_FC_F]->attr.dtype.vx_type)
    {
        scale_val[5] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_HSTATE_FC_F]);
        tail_val[5]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_HSTATE_FC_F]) * scale_val[5];
    }

    if (inputs[LSTMUNIT_ACT_HSTATE_FC_C] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_HSTATE_FC_C]->attr.dtype.vx_type)
    {
        scale_val[6] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_HSTATE_FC_C]);
        tail_val[6]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_HSTATE_FC_C]) * scale_val[6];
    }

    if (inputs[LSTMUNIT_ACT_HSTATE_FC_O] && VSI_NN_TYPE_UINT8 == inputs[LSTMUNIT_ACT_HSTATE_FC_O]->attr.dtype.vx_type)
    {
        scale_val[7] = vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_HSTATE_FC_O]);
        tail_val[7]  = -(float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_HSTATE_FC_O]) * scale_val[7];
    }

    if (outputs[LSTMUNIT_ACT_OUTPUT] && VSI_NN_TYPE_UINT8 == outputs[LSTMUNIT_ACT_OUTPUT]->attr.dtype.vx_type)
    {
        scale_val[8] = 1.0f / vsi_nn_get_tensor_scale(inputs[LSTMUNIT_ACT_OUTPUT]);
        tail_val[8]  = (float)vsi_nn_get_tensor_zero_point(inputs[LSTMUNIT_ACT_OUTPUT]);
    }

    if( VSI_SUCCESS == status)
    {
        node = vsi_nn_kernel_create_node( graph, kernel );
        if( node )
        {
            for (i = 0; i < input_num; i++)
            {
                if (inputs[i])
                {
                    in_tensor[input_cnt] = inputs[i];
                    input_cnt++;
                }
            }
            for (i = 0; i < output_num; i++)
            {
                if (outputs[i])
                {
                    out_tensor[output_cnt] = outputs[i];
                    output_cnt++;
                }
            }
            lstm_activation_param_num  = get_param_num(lstm_activation);
            if (!is_u8_type)
            {
                lstm_activation_param_num = lstm_activation_param_num - 18;
            }
            lstm_activation_in_out_num = get_in_out_num(lstm_activation);
            /* Set inputs and outputs */
            vsi_nn_kernel_node_pack_io( node_params, lstm_activation_param_num,
                    in_tensor, input_cnt, out_tensor, output_cnt );
            node_params[lstm_activation_in_out_num] = vsi_nn_kernel_scalar_create(
                    graph, F32, &logE );
            node_params[lstm_activation_in_out_num + 1] = vsi_nn_kernel_scalar_create(
                    graph, F32, &twoLogE );
            node_params[lstm_activation_in_out_num + 2] = vsi_nn_kernel_scalar_create(
                    graph, F32, &forget_bias );
            node_params[lstm_activation_in_out_num + 3] = vsi_nn_kernel_scalar_create(
                    graph, F32, &float_max );
            node_params[lstm_activation_in_out_num + 4] = vsi_nn_kernel_scalar_create(
                    graph, F32, &float_min );
            if (is_u8_type)
            {
                for (i = 0; i < 9; i++)
                {
                    node_params[lstm_activation_in_out_num + 5 + 2 * i] = vsi_nn_kernel_scalar_create(
                            graph, F32, &scale_val[i] );
                    node_params[lstm_activation_in_out_num + 6 + 2 * i] = vsi_nn_kernel_scalar_create(
                            graph, F32, &tail_val[i] );
                }
            }
            /* Pass parameters to node. */
            status  = vsi_nn_kernel_node_pass_param( node, node_params, lstm_activation_param_num );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_in_out_num] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_in_out_num + 1] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_in_out_num + 2] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_in_out_num + 3] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_in_out_num + 4] );
            if (is_u8_type)
            {
                for (i = 0; i < 18; i++)
                {
                    vsi_nn_kernel_scalar_release( &node_params[lstm_activation_in_out_num + 5 + i] );
                }
            }
        }
    }

    return node;
} /* _setup() */

__END_DECLS

REGISTER_BACKEND_CL( lstmunit_activation, _setup )
