Skip to content

Commit b207b27

Browse files
committed
Add docs
1 parent 0e8d4f8 commit b207b27

67 files changed

Lines changed: 2041 additions & 1356 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "usls"
33
edition = "2021"
4-
version = "0.1.0-beta.4"
4+
version = "0.1.0-rc.1"
55
rust-version = "1.82"
66
description = "A Rust library integrated with ONNXRuntime, providing a collection of ML models."
77
repository = "https://github.com/jamjamjon/usls"
@@ -10,6 +10,7 @@ license = "MIT"
1010
readme = "README.md"
1111
exclude = ["assets/*", "examples/*", "runs/*", "benches/*", "tests/*"]
1212

13+
1314
[dependencies]
1415
anyhow = { version = "1" }
1516
aksr = { version = "0.0.3" }
@@ -47,8 +48,6 @@ tokenizers = { version = "0.21.1" }
4748
paste = "1.0.15"
4849
base64ct = "=1.7.3"
4950

50-
[build-dependencies]
51-
prost-build = "0.13.5"
5251

5352
[dev-dependencies]
5453
argh = "0.1.13"

README.md

Lines changed: 104 additions & 252 deletions
Large diffs are not rendered by default.

build.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
use aksr::Builder;
22

33
use crate::{
4-
impl_ort_config_methods, impl_processor_config_methods,
54
models::{SamKind, YOLOPredsFormat},
65
ORTConfig, ProcessorConfig, Scale, Task, Version,
76
};
87

9-
/// Config for building models and inference
8+
/// Configuration for model inference including engines, processors, and task settings.
109
#[derive(Builder, Debug, Clone)]
1110
pub struct Config {
1211
// Basics
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,19 @@ trait DataLoaderIterator {
550550
}
551551
}
552552

553+
/// An iterator implementation for `DataLoader` that enables batch processing of images.
554+
///
555+
/// This struct is created by the `into_iter` method on `DataLoader`.
556+
/// It provides functionality for:
557+
/// - Receiving batches of images through a channel
558+
/// - Tracking progress with an optional progress bar
559+
/// - Processing images in configurable batch sizes
553560
pub struct DataLoaderIntoIterator {
561+
/// Channel receiver for getting batches of images
554562
receiver: mpsc::Receiver<Vec<Image>>,
563+
/// Optional progress bar for tracking iteration progress
555564
progress_bar: Option<ProgressBar>,
565+
/// Number of images to process in each batch
556566
batch_size: u64,
557567
}
558568

@@ -593,6 +603,15 @@ impl IntoIterator for DataLoader {
593603
}
594604
}
595605

606+
/// A borrowing iterator for `DataLoader` that enables batch processing of images.
607+
///
608+
/// This iterator is created by the `iter()` method on `DataLoader`, allowing iteration
609+
/// over batches of images without taking ownership of the `DataLoader`.
610+
///
611+
/// # Fields
612+
/// - `receiver`: A reference to the channel receiver that provides batches of images
613+
/// - `progress_bar`: An optional reference to a progress bar for tracking iteration progress
614+
/// - `batch_size`: The number of images to process in each batch
596615
pub struct DataLoaderIter<'a> {
597616
receiver: &'a mpsc::Receiver<Vec<Image>>,
598617
progress_bar: Option<&'a ProgressBar>,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
2+
/// Device types for model execution.
23
pub enum Device {
34
Cpu(usize),
45
Cuda(usize),
File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
2+
/// Data type enumeration for tensor elements.
23
pub enum DType {
34
#[default]
45
Auto,
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,53 @@ impl From<TensorElementType> for DType {
4646
}
4747

4848
/// A struct for tensor attrs composed of the names, the dtypes, and the dimensions.
49+
/// ONNX Runtime tensor attributes containing names, data types, and dimensions.
4950
#[derive(Builder, Debug, Clone, Default)]
51+
/// ONNX Runtime tensor attributes containing metadata.
5052
pub struct OrtTensorAttr {
53+
/// Tensor names.
5154
pub names: Vec<String>,
55+
/// Tensor data types.
5256
pub dtypes: Vec<TensorElementType>,
57+
/// Tensor dimensions for each tensor.
5358
pub dimss: Vec<Vec<usize>>,
5459
}
5560

61+
/// ONNX I/O structure containing input/output attributes and session.
5662
#[derive(Debug)]
5763
pub struct OnnxIo {
64+
/// Input tensor attributes.
5865
pub inputs: OrtTensorAttr,
66+
/// Output tensor attributes.
5967
pub outputs: OrtTensorAttr,
68+
/// ONNX Runtime session.
6069
pub session: Session,
70+
/// ONNX model protocol buffer.
6171
pub proto: onnx::ModelProto,
6272
}
6373

74+
/// ONNX Runtime inference engine with configuration and session management.
6475
#[derive(Debug, Builder)]
6576
pub struct Engine {
77+
/// Model file path.
6678
pub file: String,
79+
/// Model specification string.
6780
pub spec: String,
81+
/// Execution device.
6882
pub device: Device,
6983
#[args(inc)]
7084
pub iiixs: Vec<Iiix>,
7185
#[args(aka = "parameters")]
7286
pub params: Option<usize>,
7387
#[args(aka = "memory")]
7488
pub wbmems: Option<usize>,
89+
/// Input min-opt-max configurations.
7590
pub inputs_minoptmax: Vec<Vec<MinOptMax>>,
91+
/// ONNX I/O structure.
7692
pub onnx: Option<OnnxIo>,
93+
/// Timing statistics.
7794
pub ts: Ts,
95+
/// Number of dry runs for warmup.
7896
pub num_dry_run: usize,
7997

8098
// global
@@ -158,7 +176,7 @@ impl Default for Engine {
158176
// cann
159177
cann_graph_inference: true,
160178
cann_dump_graphs: false,
161-
cann_dump_om_model: false,
179+
cann_dump_om_model: true,
162180
// nnapi
163181
nnapi_cpu_only: false,
164182
nnapi_disable_cpu: false,

0 commit comments

Comments
 (0)