34 int32_t output_zeropoint,
const int32_t *input_gate_bias,
35 const int32_t *forget_gate_bias,
const int32_t *cell_gate_bias,
36 const int32_t *output_gate_bias, int16_t *input_layer_norm_coefficients,
37 int16_t *forget_layer_norm_coefficients, int16_t *cell_layer_norm_coefficients,
38 int16_t *output_layer_norm_coefficients)
40 cmsis_nn_lstm_params params_out;
42 params_out.time_major = time_major;
45 params_out.input_to_input_scaling.multiplier = params_in.effective_input_to_input_scale_a;
46 params_out.input_to_input_scaling.shift = params_in.effective_input_to_input_scale_b;
47 params_out.recurrent_to_input_scaling.multiplier = params_in.effective_recurrent_to_input_scale_a;
48 params_out.recurrent_to_input_scaling.shift = params_in.effective_recurrent_to_input_scale_b;
49 params_out.cell_to_input_scaling.multiplier = params_in.effective_cell_to_input_scale_a;
50 params_out.cell_to_input_scaling.shift = params_in.effective_cell_to_input_scale_b;
51 params_out.input_to_forget_scaling.multiplier = params_in.effective_input_to_forget_scale_a;
52 params_out.input_to_forget_scaling.shift = params_in.effective_input_to_forget_scale_b;
53 params_out.recurrent_to_forget_scaling.multiplier =
54 params_in.effective_recurrent_to_forget_scale_a;
55 params_out.recurrent_to_forget_scaling.shift = params_in.effective_recurrent_to_forget_scale_b;
56 params_out.cell_to_forget_scaling.multiplier = params_in.effective_cell_to_forget_scale_a;
57 params_out.cell_to_forget_scaling.shift = params_in.effective_cell_to_forget_scale_b;
58 params_out.input_to_cell_scaling.multiplier = params_in.effective_input_to_cell_scale_a;
59 params_out.input_to_cell_scaling.shift = params_in.effective_input_to_cell_scale_b;
60 params_out.recurrent_to_cell_scaling.multiplier = params_in.effective_recurrent_to_cell_scale_a;
61 params_out.recurrent_to_cell_scaling.shift = params_in.effective_recurrent_to_cell_scale_b;
62 params_out.input_to_output_scaling.multiplier = params_in.effective_input_to_output_scale_a;
63 params_out.input_to_output_scaling.shift = params_in.effective_input_to_output_scale_b;
65 params_out.recurrent_to_output_scaling.multiplier =
66 params_in.effective_recurrent_to_output_scale_a;
67 params_out.recurrent_to_output_scaling.shift = params_in.effective_recurrent_to_output_scale_b;
68 params_out.cell_to_output_scaling.multiplier = params_in.effective_cell_to_output_scale_a;
69 params_out.cell_to_output_scaling.shift = params_in.effective_cell_to_output_scale_b;
70 params_out.projection_scaling.multiplier = params_in.effective_proj_scale_a;
71 params_out.projection_scaling.shift = params_in.effective_proj_scale_b;
73 params_out.layer_norm_input_scaling.multiplier = params_in.layer_norm_input_scale_a;
74 params_out.layer_norm_input_scaling.shift = params_in.layer_norm_input_scale_b;
75 params_out.layer_norm_forget_scaling.multiplier = params_in.layer_norm_forget_scale_a;
76 params_out.layer_norm_forget_scaling.shift = params_in.layer_norm_forget_scale_b;
77 params_out.layer_norm_cell_scaling.multiplier = params_in.layer_norm_cell_scale_a;
78 params_out.layer_norm_cell_scaling.shift = params_in.layer_norm_cell_scale_b;
79 params_out.layer_norm_output_scaling.multiplier = params_in.layer_norm_output_scale_a;
80 params_out.layer_norm_output_scaling.shift = params_in.layer_norm_output_scale_b;
82 params_out.clip.cell = params_in.quantized_cell_clip;
83 params_out.clip.projection = params_in.quantized_proj_clip;
85 params_out.cell_state_shift = params_in.cell_scale;
87 params_out.hidden_offset = params_in.hidden_zp;
88 params_out.output_state_offset = output_zeropoint;
90 params_out.guard.input_variance = params_in.input_variance_guard;
91 params_out.guard.forget_variance = params_in.forget_variance_guard;
92 params_out.guard.cell_variance = params_in.cell_variance_guard;
93 params_out.guard.output_variance = params_in.output_variance_guard;
95 params_out.i2f_effective_bias = params_in.input_to_forget_effective_bias.data();
96 params_out.r2f_effective_bias = params_in.recurrent_to_forget_effective_bias.data();
97 params_out.i2c_effective_bias = params_in.input_to_cell_effective_bias.data();
98 params_out.r2c_effective_bias = params_in.recurrent_to_cell_effective_bias.data();
99 params_out.i2o_effective_bias = params_in.input_to_output_effective_bias.data();
100 params_out.r2o_effective_bias = params_in.recurrent_to_output_effective_bias.data();
101 params_out.i2i_effective_bias = params_in.input_to_input_effective_bias.data();
102 params_out.r2i_effective_bias = params_in.recurrent_to_input_effective_bias.data();
103 params_out.projection_effective_bias = params_in.projection_effective_bias.data();
105 params_out.hidden_scaling.multiplier = params_in.effective_hidden_scale_a;
106 params_out.hidden_scaling.shift = params_in.effective_hidden_scale_b;
108 params_out.input_gate_bias = input_gate_bias;
109 params_out.forget_gate_bias = forget_gate_bias;
110 params_out.cell_gate_bias = cell_gate_bias;
111 params_out.output_gate_bias = output_gate_bias;
113 params_out.layer_norm.input_weight = input_layer_norm_coefficients;
114 params_out.layer_norm.forget_weight = forget_layer_norm_coefficients;
115 params_out.layer_norm.cell_weight = cell_layer_norm_coefficients;
116 params_out.layer_norm.output_weight = output_layer_norm_coefficients;
118 params_out.activation.min = std::numeric_limits<int16_t>::min();
119 params_out.activation.max = std::numeric_limits<int16_t>::max();