Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: matteocarnelos/microflow-rs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.3
Choose a base ref
...
head repository: matteocarnelos/microflow-rs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 11 commits
  • 6 files changed
  • 3 contributors

Commits on Aug 13, 2024

  1. pinning esp-hal version

    salsasteve committed Aug 13, 2024
    Copy the full SHA
    17c443d View commit details

Commits on Aug 27, 2024

  1. Update examples/esp32/Cargo.toml

    Co-authored-by: Matteo Carnelos <[email protected]>
    salsasteve and matteocarnelos authored Aug 27, 2024
    Copy the full SHA
    470552f View commit details
  2. Merge pull request #3 from salsasteve/hal-updates

    pinning esp-hal version
    matteocarnelos authored Aug 27, 2024
    Copy the full SHA
    3523a50 View commit details

Commits on Oct 1, 2024

  1. Update README.md

    matteocarnelos authored Oct 1, 2024
    Copy the full SHA
    d82211e View commit details
  2. examples/esp32: Fix outdated esp-hal dependencies

    matteocarnelos committed Oct 1, 2024
    Copy the full SHA
    71de093 View commit details

Commits on Dec 12, 2024

  1. docs: Add link to documentation

    matteocarnelos authored Dec 12, 2024
    Copy the full SHA
    d68b1fd View commit details

Commits on Jan 21, 2025

  1. Update README.md

    matteocarnelos authored Jan 21, 2025
    Copy the full SHA
    18135ca View commit details
  2. chore: Update copyright notice

    matteocarnelos authored Jan 21, 2025
    Copy the full SHA
    813fbf1 View commit details

Commits on Jan 22, 2025

  1. fix(examples/arduino-uno): Update avr-device crate

    matteocarnelos committed Jan 22, 2025
    Copy the full SHA
    3b93a05 View commit details
  2. fix(examples/esp32): Update esp-hal crate

    matteocarnelos committed Jan 22, 2025
    Copy the full SHA
    4ded065 View commit details
  3. Merge pull request #5 from matteocarnelos/fix-examples

    Fix examples
    matteocarnelos authored Jan 22, 2025
    Copy the full SHA
    2fb39af View commit details
Showing with 56 additions and 76 deletions.
  1. +22 −1 README.md
  2. +1 −1 examples/arduino-uno/Cargo.toml
  3. +3 −3 examples/esp32/Cargo.toml
  4. +11 −25 examples/esp32/examples/person_detect.rs
  5. +8 −21 examples/esp32/examples/sine.rs
  6. +11 −25 examples/esp32/examples/speech.rs
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -56,6 +56,8 @@ fn main() {
}
```

**[Documentation](https://docs.rs/microflow)**

## Examples

The examples provided with MicroFlow can be found in the `examples` folder.
@@ -112,6 +114,25 @@ Contributors are welcome.
For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.

## Citation

The MicroFlow paper has been published in Elsevier's [Internet of Things](https://www.sciencedirect.com/science/article/pii/S2542660525000113) journal and can be cited as follows:

```bibtex
@article{CARNELOS2025101498,
title = {MicroFlow: An Efficient Rust-Based Inference Engine for TinyML},
journal = {Internet of Things},
volume = {30},
pages = {101498},
year = {2025},
issn = {2542-6605},
doi = {https://doi.org/10.1016/j.iot.2025.101498},
url = {https://www.sciencedirect.com/science/article/pii/S2542660525000113},
author = {Matteo Carnelos and Francesco Pasti and Nicola Bellotto},
keywords = {TinyML, Rust, Neural networks, Embedded systems, IoT}
}
```

## License

Licensed under either of
@@ -121,4 +142,4 @@ Licensed under either of

at your option.

Copyright © 2024, [Matteo Carnelos](https://github.com/matteocarnelos)
Copyright © 2025, [Matteo Carnelos](https://github.com/matteocarnelos)
2 changes: 1 addition & 1 deletion examples/arduino-uno/Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ version = "0.0.0"
edition = "2021"

[dependencies]
avr-device = "0.5"
avr-device = { version = "0.7", features = ["atmega328p"] }
ufmt = "0.2"
ufmt_float = { git = "https://github.com/tl8roy/ufmt_float" }
panic-halt = "0.2"
6 changes: 3 additions & 3 deletions examples/esp32/Cargo.toml
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@ version = "0.0.0"
edition = "2021"

[dependencies]
esp-println = { version = "0.3", features = ["esp32"] }
esp-backtrace = { version = "0.5", features = ["esp32", "panic-handler", "print-uart"] }
hal = { package = "esp-hal", git = "https://github.com/esp-rs/esp-hal", features = ["esp32"] }
esp-println = { version = "0.13", features = ["esp32"] }
esp-backtrace = { version = "0.15", features = ["esp32", "panic-handler", "println"] }
esp_hal = { package = "esp-hal", version = "0.23", features = ["esp32"] }
microflow = { path = "../.." }
nalgebra = { version = "0.32", default-features = false, features = ["macros"] }
libm = "0.2"
36 changes: 11 additions & 25 deletions examples/esp32/examples/person_detect.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#![no_std]
#![no_main]

use esp_hal::{clock::CpuClock, main, rtc_cntl::Rtc};
use esp_println::println;
use hal::clock::CpuClock;
use hal::{
clock::ClockControl, peripherals::Peripherals, prelude::*, rtc_cntl::Rtc,
system::SystemControl, timer::timg::TimerGroup,
};
use microflow::buffer::Buffer2D;
use microflow::model;

@@ -34,37 +30,27 @@ fn print_prediction(prediction: Buffer2D<f32, 1, 2>) {
);
}

#[entry]
#[main]
fn main() -> ! {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze();
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
let rtc = Rtc::new(peripherals.LPWR);

let mut rtc = Rtc::new(peripherals.LPWR, None);
let timer_group0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new_async(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;

rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();

let start = rtc.get_time_us();
let start = rtc.time_since_boot();
let person_predicted = PersonDetect::predict_quantized(features::PERSON);
let end = rtc.get_time_us();
let end = rtc.time_since_boot();
println!(" ");
println!("Input sample: 'person.bmp'");
print_prediction(person_predicted);
println!("Execution time: {} us", end - start);
println!("Execution time: {}", end - start);

let start = rtc.get_time_us();
let start = rtc.time_since_boot();
let no_person_predicted = PersonDetect::predict_quantized(features::NO_PERSON);
let end = rtc.get_time_us();
let end = rtc.time_since_boot();
println!(" ");
println!("Input sample: 'no_person.bmp'");
print_prediction(no_person_predicted);
println!("Execution time: {} us", end - start);
println!("Execution time: {}", end - start);

loop {}
}
29 changes: 8 additions & 21 deletions examples/esp32/examples/sine.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#![no_std]
#![no_main]

use esp_hal::{clock::CpuClock, main, rtc_cntl::Rtc};
use esp_println::println;
use hal::{
clock::ClockControl, peripherals::Peripherals, prelude::*, rtc_cntl::Rtc,
system::SystemControl, timer::timg::TimerGroup,
};
use libm::sinf;
use microflow::model;
use nalgebra::matrix;
@@ -15,32 +12,22 @@ use esp_backtrace as _;
#[model("../../models/sine.tflite")]
struct Sine;

#[entry]
#[main]
fn main() -> ! {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();

let mut rtc = Rtc::new(peripherals.LPWR, None);
let timer_group0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new_async(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;

rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
let rtc = Rtc::new(peripherals.LPWR);

let x = 0.5;
let start = rtc.get_time_us();
let start = rtc.time_since_boot();
let y_predicted = Sine::predict(matrix![x])[0];
let end = rtc.get_time_us();
let end = rtc.time_since_boot();
let y_exact = sinf(x);
println!(" ");
println!("Predicted sin({}): {}", x, y_predicted);
println!("Exact sin({}): {}", x, y_exact);
println!("Error: {}", y_exact - y_predicted);
println!("Execution time: {} us", end - start);
println!("Execution time: {}", end - start);

loop {}
}
36 changes: 11 additions & 25 deletions examples/esp32/examples/speech.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#![no_std]
#![no_main]

use esp_hal::{clock::CpuClock, main, rtc_cntl::Rtc};
use esp_println::println;
use hal::clock::CpuClock;
use hal::{
clock::ClockControl, peripherals::Peripherals, prelude::*, rtc_cntl::Rtc,
system::SystemControl, timer::timg::TimerGroup,
};
use microflow::buffer::Buffer2D;
use microflow::model;

@@ -38,37 +34,27 @@ fn print_prediction(prediction: Buffer2D<f32, 1, 4>) {
);
}

#[entry]
#[main]
fn main() -> ! {
let peripherals = Peripherals::take();
let system = SystemControl::new(peripherals.SYSTEM);
let clocks = ClockControl::configure(system.clock_control, CpuClock::Clock240MHz).freeze();
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
let rtc = Rtc::new(peripherals.LPWR);

let mut rtc = Rtc::new(peripherals.LPWR, None);
let timer_group0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new_async(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;

rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();

let start = rtc.get_time_us();
let start = rtc.time_since_boot();
let yes_predicted = Speech::predict_quantized(features::YES);
let end = rtc.get_time_us();
let end = rtc.time_since_boot();
println!(" ");
println!("Input sample: 'yes.wav'");
print_prediction(yes_predicted);
println!("Execution time: {} us", end - start);
println!("Execution time: {}", end - start);

let start = rtc.get_time_us();
let start = rtc.time_since_boot();
let no_predicted = Speech::predict_quantized(features::NO);
let end = rtc.get_time_us();
let end = rtc.time_since_boot();
println!(" ");
println!("Input sample: 'no.wav'");
print_prediction(no_predicted);
println!("Execution time: {} us", end - start);
println!("Execution time: {}", end - start);

loop {}
}