native_neural_network 0.1.6

Lib no_std Rust for native neural network (.rnn)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::rnn_format::RnnHandle;

pub fn find_blob_index(handle: &RnnHandle<'_, '_>, name: &str) -> Option<usize> {
    (0..handle.blobs.len()).find(|&i| handle.blob_name(i) == Some(name))
}

pub fn total_blob_payload_bytes(handle: &RnnHandle<'_, '_>) -> Option<usize> {
    let mut total = 0usize;
    for blob in handle.blobs {
        total = total.checked_add(usize::try_from(blob.length).ok()?)?;
    }
    Some(total)
}