Skip to content

Adding the example for the sensor based data collection and running on a riscv device - #250

Open
shrit wants to merge 75 commits into
mlpack:masterfrom
shrit:mpu
Open

shrit wants to merge 75 commits into
mlpack:masterfrom
shrit:mpu

Conversation

@shrit

@shrit shrit commented Jun 28, 2026

Copy link
Copy Markdown
Member

No description provided.

@github-actions

Copy link
Copy Markdown

Binder 👈 Launch a binder notebook on branch shrit/examples/mpu

@rcurtin rcurtin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am really hesitant about this design. The amount of complexity in this code is huge: it contains its own I2C library specific to each of the sensors in the example, and I think if I understand right that it is basically written entirely by Claude?

(It also seems like the training and inference programs aren't here, but I assume you will push them soon.)

The question I have is: who is the target audience here? Nobody wants to read 3000 lines of hardware control code to understand it. How will someone approach the example? The other examples we have are all written so that someone can read through the entire source and know what is going on. But that's unrealistic here. Do you think we can go through and pare back the code a huge amount? It's an example, not an enterprise application, so all of the "fancy" stuff like short-option and long-option parsing are just unnecessary, in my opinion.

There is a huge amount of other error checking and support code that's also probably unnecessary (at least that is what I have seen with lots of other Claude-generated code). When there is too much code, even if it really is checking for every possible case, a reader will never make it through the whole file and learn what we want them to learn (i.e. how to use mlpack). In my eyes that makes it sort of defeat the purpose of the tutorial.

@@ -0,0 +1,725 @@
# - Find mlpack

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How will we keep this file up to date? There are now copies of mlpack.cmake floating all over the place, but the upstream one in mlpack updates from time to time.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a very good question, that I do not have the answer for it, maybe using the CI ? github actions that can check every new PR ?

shrit and others added 20 commits July 13, 2026 19:55
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
shrit and others added 28 commits November 8, 2026 18:44
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>
Signed-off-by: Omar Shrit <[email protected]>

@rcurtin rcurtin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for handling all the issues. I haven't had a chance to test the updated programs on my Milk-V but if you have done that and it all still works reasonably, then I think everything is basically good to go here. I re-reviewed the code at a high level but I did not go through with a fine-toothed comb to make sure that everything was completely correct (I am trusting that we either caught any issues like that in the previous review, or that the example is validated by the fact that you've actually run it all successfully). Two comments before we merge:

  • Did you mean to add the movement_recognition/doc/ folder? It seems like that has lots and lots of stuff that was useful in generating the tutorial, but isn't actually useful for a reader of the tutorial. Just from the perspective of minimizing information, so that we don't overwhelm someone who is looking at the tutorial, I think it's better to keep that out of the repository.

  • Did you manage to fix the output when infer gets run for the IMU warning? The tutorial gives this output:

[root@milkv-duo]~# ./infer accel /dev/i2c-0 model
loaded model from 'model' (window 256, 8 classes)
Proceeding despite the IMU warning(s) above.
predict: sitting
predict: sitting
predict: sitting
predict: sitting
predict: sitting
predict: sitting
predict: sitting
predict: sitting
...

but I think (but did not check) that we got rid of that Proceeding despite the IMU warning(s) above message. I know it had to do with the reported ID of the device differing with different models of the IMU board (or something along those lines), and I know there were some changes here that I thought allowed both board IDs to be accepted... but I don't know if the actual output is fixed now.

Can you check if it is? If so, we can update the output in the tutorial back in the mlpack repository after we merge this, and then also remove the bit in scripts/build-docs.sh that ignores the URL for this code to make the documentation build pass 😄

@@ -0,0 +1,291 @@
# Binary size: analysis, results, and how to reproduce

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also in the interest of not overwhelming a reader... I think it might be better to leave this document out. Personally I found it interesting, but, I am a developer. It feels more like something that I would want to know during a PR review, as opposed to that a user would need to know during the tutorial. Basically there are two takeaways I see from this document:

  1. If you want to minimize size even more, you need to avoid use of cereal for serialization and, I assume, instead just use Armadillo's mat.load() functionality to load the weights directly once the matrix has been created. That would probably be a nice follow-up tutorial or maybe example documentation somewhere, so, this particular point will eventually be covered elsewhere. (I'm interested to see how much space that saves!)

  2. The options we have chosen for compilation are the right ones to pick, and if you don't have -DMLPACK_DISABLE_STB then the binary ends up being larger. Other things are harder to remove. (This seems non-actionable for a reader, since, we are already telling them what their best option is right now. No need to justify that with all kinds of detailed possibilities.)

Anyway, not sure if you meant to check this in. In either case, as a developer I did find it interesting to read and the results here may be able to guide future changes we make to mlpack to reduce binary size.

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.

2 participants