Update README && *.h of libs

This commit is contained in:
Wang Wang Wang 2019-08-08 18:06:41 +08:00
parent ff334691dc
commit 45537c741d
10 changed files with 95 additions and 27 deletions

View File

@ -1,3 +1,16 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DL_LIB_H #ifndef DL_LIB_H
#define DL_LIB_H #define DL_LIB_H

View File

@ -1,3 +1,16 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DL_LIB_COEFGETTER_IF_H #ifndef DL_LIB_COEFGETTER_IF_H
#define DL_LIB_COEFGETTER_IF_H #define DL_LIB_COEFGETTER_IF_H

View File

@ -1,3 +1,16 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DL_LIB_CONV_QUEUE_H #ifndef DL_LIB_CONV_QUEUE_H
#define DL_LIB_CONV_QUEUE_H #define DL_LIB_CONV_QUEUE_H

View File

@ -1,3 +1,16 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DL_LIB_CONVQ_QUEUE_H #ifndef DL_LIB_CONVQ_QUEUE_H
#define DL_LIB_CONVQ_QUEUE_H #define DL_LIB_CONVQ_QUEUE_H
@ -24,7 +37,7 @@ typedef struct {
*/ */
dl_convq_queue_t *dl_convq_queue_alloc(int n, int c); dl_convq_queue_t *dl_convq_queue_alloc(int n, int c);
void dl_convq_to_matrix2dq(dl_convq_queue_t *cq, dl_matrix2dq_t* out); void dl_convq_to_matrix2dq(dl_convq_queue_t *cq, dl_matrix2dq_t* out, int row);
/** /**
* @brief Free a fixed-point convolution queue * @brief Free a fixed-point convolution queue
@ -70,18 +83,6 @@ void dl_convq_queue_push_by_qmf(dl_convq_queue_t *cq, fptp_t* item, int m_bit, i
*/ */
qtp_t *dl_get_queue_itemq(dl_convq_queue_t *cq, int offset); qtp_t *dl_get_queue_itemq(dl_convq_queue_t *cq, int offset);
/**
* @brief Does a sigmoid operation on the one of element in the convolution queue.
* Gets the pointer of element in the convolution queue by offset, and does a
* sigmoid operation by this pointer, then return the pointer
*
* @param cq Input fixed-point convolution queue
* @param offset Offset from the front of the queue
* @return Pointer of the element
*/
qtp_t *dl_sigmoid_step_q(dl_convq_queue_t *cq, int offset);
void dl_tanh_convq(dl_convq_queue_t *cq, int last_num);
/** /**
* @brief Does a tanh operation on the one of element in the convolution queue. * @brief Does a tanh operation on the one of element in the convolution queue.
* Gets the pointer of element in the convolution queue by offset, and does a * Gets the pointer of element in the convolution queue by offset, and does a
@ -91,8 +92,19 @@ void dl_tanh_convq(dl_convq_queue_t *cq, int last_num);
* @param offset Offset from the front of the queue * @param offset Offset from the front of the queue
* @return Pointer of the element * @return Pointer of the element
*/ */
qtp_t *dl_tanh_step_q(dl_convq_queue_t *cq, int offset); void dl_tanh_convq(dl_convq_queue_t *cq, int last_num);
qtp_t *dl_relu_step_q(dl_convq_queue_t *cq, fptp_t clip, int offset);
/**
* @brief Does a relu operation on the one of element in the convolution queue.
* Gets the pointer of element in the convolution queue by offset, and does a
* relu operation by this pointer, then return the pointer
*
* @param cq Input fixed-point convolution queue
* @param offset Offset from the front of the queue
* @return Pointer of the element
*/
void dl_relu_convq(dl_convq_queue_t *cq, fptp_t clip, int last_num);
/** /**
* @brief Does a softmax operation on the one of element in the convolution queue. * @brief Does a softmax operation on the one of element in the convolution queue.
* Gets the pointer of element in the convolution queue by offset, input data * Gets the pointer of element in the convolution queue by offset, input data
@ -121,8 +133,6 @@ fptp_t * dl_softmax_step_q(dl_convq_queue_t *cq, int offset, fptp_t *out);
* @param shift Shift ratio used in dot operation between two 16-bit fixed point vector * @param shift Shift ratio used in dot operation between two 16-bit fixed point vector
* @return The result of atrous convolution * @return The result of atrous convolution
*/ */
qtp_t *dl_atrous_conv1dq_step(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift);
qtp_t *dl_atrous_conv1dq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size, qtp_t *dl_atrous_conv1dq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift); dl_matrix2dq_t* kernel, dl_matrix2dq_t* bias, int shift);
/** /**
@ -147,17 +157,13 @@ qtp_t *dl_atrous_conv1dq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate,
* @gate_shift Shift ratio used in gate operation between two 16-bit fixed point vector * @gate_shift Shift ratio used in gate operation between two 16-bit fixed point vector
* @return The result of dilation layer * @return The result of dilation layer
*/ */
qtp_t *dl_dilation_layerq_step(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias,
dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias,
int filter_shift, int gate_shift);
qtp_t *dl_dilation_layerq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size, qtp_t *dl_dilation_layerq(dl_convq_queue_t *in, dl_convq_queue_t *out, int rate, int size,
dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias, dl_matrix2dq_t* filter_kernel, dl_matrix2dq_t* filter_bias,
dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias, dl_matrix2dq_t* gate_kernel, dl_matrix2dq_t* gate_bias,
int filter_shift, int gate_shift); int filter_shift, int gate_shift);
dl_matrix2dq_t *dl_basic_lstm_layer1_q(const dl_convq_queue_t *in, dl_matrix2dq_t *state_c, dl_matrix2dq_t *state_h, dl_matrix2dq_t *dl_basic_lstm_layer1_q(const dl_convq_queue_t *in, dl_matrix2dq_t *state_c, dl_matrix2dq_t *state_h,
const dl_matrix2dq_t *weight, const dl_matrix2dq_t *bias, int shift); const dl_matrix2dq_t *weight, const dl_matrix2dq_t *bias, int step, int shift);
void test_atrous_convq(int size, int rate, int in_channel, int out_channel); void test_atrous_convq(int size, int rate, int in_channel, int out_channel);
#endif #endif

View File

@ -1,3 +1,16 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DL_LIB_MATRIX_H #ifndef DL_LIB_MATRIX_H
#define DL_LIB_MATRIX_H #define DL_LIB_MATRIX_H

View File

@ -1,3 +1,16 @@
// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DL_LIB_MATRIXQ_H #ifndef DL_LIB_MATRIXQ_H
#define DL_LIB_MATRIXQ_H #define DL_LIB_MATRIXQ_H

View File

@ -14,7 +14,6 @@ static const esp_mn_iface_t *multinet = &MULTINET_MODEL;
void multinetTask(void *arg) void multinetTask(void *arg)
{ {
model_iface_data_t *model_data = arg; model_iface_data_t *model_data = arg;
int frequency = multinet->get_samp_rate(model_data);
int audio_chunksize = multinet->get_samp_chunksize(model_data); int audio_chunksize = multinet->get_samp_chunksize(model_data);
int chunk_num = multinet->get_samp_chunknum(model_data); int chunk_num = multinet->get_samp_chunknum(model_data);
int16_t *buffer = malloc(audio_chunksize * sizeof(int16_t)); int16_t *buffer = malloc(audio_chunksize * sizeof(int16_t));
@ -50,9 +49,8 @@ void multinet_test()
model_iface_data_t *model_data = multinet->create(&MULTINET_COEFF, 6000); model_iface_data_t *model_data = multinet->create(&MULTINET_COEFF, 6000);
//define_speech_commands(multinet, model_data); //define_speech_commands(multinet, model_data);
int audio_chunksize = multinet->get_samp_chunksize(model_data);
printf("multinet RAM size: %d\nRAM size after multinet init: %d\n", printf("multinet RAM size: %d\nRAM size after multinet init: %d\n",
start_size - heap_caps_get_free_size(MALLOC_CAP_8BIT), heap_caps_get_free_size(MALLOC_CAP_8BIT)); start_size - heap_caps_get_free_size(MALLOC_CAP_8BIT), heap_caps_get_free_size(MALLOC_CAP_8BIT));
xTaskCreatePinnedToCore(&multinetTask, "multinet", 2 * 1024, (void*)model_data, 5, NULL, 0); xTaskCreatePinnedToCore(&multinetTask, "multinet", 2 * 1024, (void*)model_data, 5, NULL, 1);
} }

View File

@ -52,7 +52,6 @@ void wakenet_test()
//Initialize wakenet model //Initialize wakenet model
model_iface_data_t *model_data = wakenet->create(model_coeff_getter, DET_MODE_90); model_iface_data_t *model_data = wakenet->create(model_coeff_getter, DET_MODE_90);
int audio_chunksize = wakenet->get_samp_chunksize(model_data);
printf("WakeNet RAM size: %d\nRAM size after WakeNet init: %d\n", printf("WakeNet RAM size: %d\nRAM size after WakeNet init: %d\n",
start_size - heap_caps_get_free_size(MALLOC_CAP_8BIT), heap_caps_get_free_size(MALLOC_CAP_8BIT)); start_size - heap_caps_get_free_size(MALLOC_CAP_8BIT), heap_caps_get_free_size(MALLOC_CAP_8BIT));

View File

@ -9,7 +9,7 @@ MultiNet uses the **MFCC features** of an audio clip as input, and the **phoneme
## Commands Recognition Process ## Commands Recognition Process
1. Add customized commands to the speech command queue. 1. Add customized commands to the speech command queue.
2. Prepare an audio clip of 30 ms (16 KHz, 6 bit, mono). 2. Prepare an audio clip of 30 ms (16 KHz, 16 bit, mono).
3. Input this audio to the MFCC model and get its **MFCC features**. 3. Input this audio to the MFCC model and get its **MFCC features**.
4. Input the obtained **MFCC features** to MultiNet and get the output **phoneme**. 4. Input the obtained **MFCC features** to MultiNet and get the output **phoneme**.
5. Input the obtained **phoneme** to the Language model and get the output. 5. Input the obtained **phoneme** to the Language model and get the output.