Skip to content

Commit bdf970b

Browse files
committed
explicit mli_tensors initialization
1 parent f9ce67c commit bdf970b

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

examples/example_kws_speech/kws/dsconv_lstm_nn/dsconv_lstm_nn_model_impl.cc

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,10 @@ kws_status kws_dsconv_lstm_nn::audio_features_extract(const sample_t *in_frame,
254254
y_mem->nn.fex_phase.ir_buf_y, x_mem->nn.fex_phase.ir_buf_x);
255255
if (fbanks_num == kFbankNumBins) {
256256
mli_tensor out_fx_features = {
257-
(void *)out_features, kFbankNumBins * sizeof(out_features[0]), {0}, {0}, 0,
258-
MLI_EL_FX_8, {kFbankFraqBits}
257+
.data = (void *)out_features,
258+
.capacity = kFbankNumBins * sizeof(out_features[0]),
259+
.el_type = MLI_EL_FX_8,
260+
.el_params.fx.frac_bits = kFbankFraqBits,
259261
};
260262
if (MLI_STATUS_OK !=
261263
mli_hlp_float_to_fx_tensor(y_mem->nn.fex_phase.out_features, kFbankNumBins,&out_fx_features))
@@ -279,9 +281,12 @@ kws_status kws_dsconv_lstm_nn::nn_inference(const int8_t *in_features, float *ou
279281
// Convolution Phase
280282
{
281283
mli_tensor input = {
282-
(void *)in_features, kFeatureVectorsForInference * kFbankNumBins * sizeof(in_features[0]),
283-
{0}, {1, kFeatureVectorsForInference, kFbankNumBins}, 3,
284-
MLI_EL_FX_8, {kFbankFraqBits}
284+
.data = (void *)in_features,
285+
.capacity = kFeatureVectorsForInference * kFbankNumBins * sizeof(in_features[0]),
286+
.shape = {1, kFeatureVectorsForInference, kFbankNumBins},
287+
.rank = 3,
288+
.el_type = MLI_EL_FX_8,
289+
.el_params.fx.frac_bits = kFbankFraqBits,
285290
};
286291

287292
// LAYER 1
@@ -343,13 +348,23 @@ kws_status kws_dsconv_lstm_nn::nn_inference(const int8_t *in_features, float *ou
343348
// LAYER 5
344349
// init structures for LSTM layer
345350
const uint32_t lstm_cell_size = m->L5_lstm_bias.shape[1];
346-
mli_tensor lstm_prev_out = { ir_X.data, ir_X.capacity, {0}, {lstm_cell_size}, 1, MLI_EL_FX_16, {7} };
351+
mli_tensor lstm_prev_out = {
352+
.data = ir_X.data,
353+
.capacity = ir_X.capacity,
354+
.shape = {lstm_cell_size},
355+
.rank = 1,
356+
.el_type = MLI_EL_FX_16,
357+
.el_params.fx.frac_bits = 7,
358+
};
347359
mli_tensor lstm_ir = { (void *)x_mem->nn.rnn_phase.lstm_ir_data, sizeof(x_mem->nn.rnn_phase.lstm_ir_data) };
348360
const mli_rnn_cell_cfg lstm_cfg = {m->lstm_mode, m->lstm_act, &lstm_ir};
349361
mli_tensor lstm_cell = {
350-
(void *)y_mem->nn.rnn_phase.lstm_cell_data, sizeof(y_mem->nn.rnn_phase.lstm_cell_data),
351-
{0}, {lstm_cell_size}, 1,
352-
MLI_EL_FX_16, {m->L5_lstm_cell_fraq}
362+
.data = (void *)y_mem->nn.rnn_phase.lstm_cell_data,
363+
.capacity = sizeof(y_mem->nn.rnn_phase.lstm_cell_data),
364+
.shape = {lstm_cell_size},
365+
.rank = 1,
366+
.el_type = MLI_EL_FX_16,
367+
.el_params.fx.frac_bits = m->L5_lstm_cell_fraq,
353368
};
354369

355370
// Clear state buffers and state tensors description completion

0 commit comments

Comments
 (0)