Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conv1d and batchnorm1d layers #209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Anirudh0707
Copy link

No description provided.

@ghost
Copy link

ghost commented Oct 9, 2020

CLA assistant check
All CLA requirements met.

@Anirudh0707 Anirudh0707 force-pushed the master branch 2 times, most recently from 12d4184 to b85cda2 Compare October 14, 2020 09:43
Copy link
Collaborator

@harsha-simhadri harsha-simhadri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code compiles, runs as expected. numerical checks passed.
Minor modifications, additional code explanation needed.
Possible superfluous code in conv1d_utils.*

README.md Outdated Show resolved Hide resolved
c_reference/tests/kws/test_keyword_spotting.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_keyword_spotting.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_keyword_spotting.c Outdated Show resolved Hide resolved
c_reference/include/conv_utils.h Outdated Show resolved Hide resolved

const ConvLayers_LR_Params* tparams= (ConvLayers_LR_Params*) params;

if (padding == -1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the header files doesn't say much about what setting padding to -1 (or any other value) means

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some documentation for padding. I removed this -1 part altogether to avoid confusions

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the -1 for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally thought of keeping a case to calculate the padding automatically to maintain the time steps.

So if it was -1, the padding would be calculated such that input time steps would be equal to the output time steps. It was similar to the "same" convolution in tensorflow

But since it would be confusing for the user, I removed those lines

c_reference/src/conv1d.c Outdated Show resolved Hide resolved
c_reference/src/conv_utils.c Outdated Show resolved Hide resolved
@@ -0,0 +1,272 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • We need some description of the overall architecture, and clarification over the form of input being tested and the nature of output.
  • can this code be extended for streaming data easily?
  • The file name could also be more specific as to which model arch for keyword spotting tested here.

Copy link
Author

@Anirudh0707 Anirudh0707 Oct 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the description and a note on what to cater to when porting the code to the microcontroller.

The code needs minor modifications for handling the streaming data. These changes are mostly variable assignments, for example fixing input streaming buffer it steps, feature length

I've changed the file to phoneme_det_cnn_rnn to signify the use of the combined arch

memcpy(rnn_out + ((out_index++)*RNN_O_F), temp_hiddenstate, rnn_hidden*sizeof(float));
}

// Backward Pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forward and backward passes could be explained a bit in text here so the reader can follow the intent.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the bricking to a separate file altogether. This bricking module has been added to the src folder, so that it can be used as function for other applications as well.

I've added a detailed documentation and line comments explaining how the code works. I've even included notes on how to use the bi-directional option and have highlighted the constrains for the bi-directional application

Copy link
Contributor

@ShikharJ ShikharJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a quick pass. I'll look more thoroughly after these minor changes are updated.

c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/tests/conv1d/conv1d_regular/test_conv1d.c Outdated Show resolved Hide resolved
c_reference/tests/dscnn/test_dscnn_lr.c Outdated Show resolved Hide resolved
c_reference/include/dscnn.h Outdated Show resolved Hide resolved
c_reference/src/conv_utils.c Outdated Show resolved Hide resolved
c_reference/src/conv_utils.c Outdated Show resolved Hide resolved
@ShikharJ
Copy link
Contributor

Also can we have more expressive macro names than O_T, I_T, O_F and I_F in the weight files?

@Anirudh0707
Copy link
Author

Anirudh0707 commented Oct 17, 2020

Also can we have more expressive macro names than O_T, I_T, O_F and I_F in the weight files?

I've incorporated all the modifications as instructed. I'll work on unifying the test benches and will rectify the macro expressiveness . I'll make these changes and push the commit for the same shortly

@Anirudh0707
Copy link
Author

Also can we have more expressive macro names than O_T, I_T, O_F and I_F in the weight files?

I've changed the macros to a more expressive name. I have also combined the test-bench files as mentioned above

Copy link
Contributor

@ShikharJ ShikharJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is riddled with typos, and it makes little sense to point them out one by one. Please spend some time self-reviewing the code and documentation.

c_reference/include/utils.h Outdated Show resolved Hide resolved
c_reference/include/utils.h Outdated Show resolved Hide resolved
c_reference/include/utils.h Outdated Show resolved Hide resolved
c_reference/include/utils.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
Copy link
Contributor

@ShikharJ ShikharJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not making any optimization passes over this as of now. Otherwise it looks good. Some minor comments.

c_reference/src/utils.c Outdated Show resolved Hide resolved
c_reference/src/utils.c Outdated Show resolved Hide resolved
c_reference/src/utils.c Outdated Show resolved Hide resolved
c_reference/include/rnn_bricked.h Outdated Show resolved Hide resolved
c_reference/include/rnn_bricked.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Outdated Show resolved Hide resolved
c_reference/src/conv1d.c Show resolved Hide resolved
c_reference/tests/conv1d/test_conv1d.c Show resolved Hide resolved
@Anirudh0707 Anirudh0707 requested a review from ShikharJ November 13, 2020 16:33
@Anirudh0707 Anirudh0707 changed the title Created and tested conv1d layers and dscnn blocks Conv1d and batchnorm1d layers Jul 2, 2021
Copy link
Contributor

@ShikharJ ShikharJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments, full review pending.

c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
@Anirudh0707
Copy link
Author

Sorry for the delay in the new commit. All the changes have been made. I have even added a couple of extra lines of comments for the error metrics for better clarity.

Copy link
Contributor

@ShikharJ ShikharJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, otherwise looks good to me.

c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
c_reference/tests/kws/test_phoneme_det_cnn_rnn.c Outdated Show resolved Hide resolved
c_reference/tests/conv1d/test_conv1d.c Outdated Show resolved Hide resolved
c_reference/include/dscnn.h Show resolved Hide resolved
c_reference/src/conv1d.c Outdated Show resolved Hide resolved
c_reference/src/conv1d.c Outdated Show resolved Hide resolved
c_reference/src/conv1d.c Outdated Show resolved Hide resolved
c_reference/src/conv1d.c Outdated Show resolved Hide resolved
c_reference/include/conv1d.h Show resolved Hide resolved
Copy link
Contributor

@ShikharJ ShikharJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @harsha-simhadri This can be merged now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants