Skip to content

Commit 25b3801

Browse files
committed
Move *towards* no-std support for bimm.
1 parent ce64684 commit 25b3801

27 files changed

+67
-52
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dirs = "^6.0.0"
3232
# > cudarc = { workspace = true, features = ["nvrtc"], optional = true }
3333
cudarc = "0.16.6"
3434

35-
bimm-contracts = "^0.19.1"
35+
bimm-contracts = "^0.19.2"
3636

3737
# Burn coupled-dependencies
3838
globwalk = "^0.9.1"

crates/bimm/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ criterion = { workspace = true }
3434

3535

3636
[features]
37-
default = ["std"]
37+
default = []
3838
std = []
39-
wgpu = ["burn/wgpu"]
4039

4140
[[bench]]
4241
name = "drop_block"

crates/bimm/src/cache/disk.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! # Cache Policy
22
33
use crate::cache::disk;
4+
use alloc::string::String;
45
use anyhow::bail;
56
use burn::config::Config;
67
use burn::data::network::downloader;

crates/bimm/src/cache/prefabs.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
use crate::cache::weights::{
44
PretrainedWeightsDescriptor, PretrainedWeightsMap, StaticPretrainedWeightsMap,
55
};
6+
use alloc::collections::BTreeMap;
7+
use alloc::format;
8+
use alloc::string::{String, ToString};
9+
use alloc::sync::Arc;
610
use anyhow::bail;
711
use burn::config::Config;
8-
use std::collections::BTreeMap;
9-
use std::fmt::Debug;
10-
use std::sync::Arc;
12+
use core::fmt::Debug;
1113

1214
/// Static builder for a [`PreFabConfig`]
1315
pub struct StaticPreFabConfig<C>
@@ -63,8 +65,8 @@ where
6365
{
6466
fn fmt(
6567
&self,
66-
f: &mut std::fmt::Formatter<'_>,
67-
) -> std::fmt::Result {
68+
f: &mut core::fmt::Formatter<'_>,
69+
) -> core::fmt::Result {
6870
self.to_prefab().fmt(f)
6971
}
7072
}
@@ -94,11 +96,11 @@ where
9496
{
9597
fn fmt(
9698
&self,
97-
f: &mut std::fmt::Formatter<'_>,
98-
) -> std::fmt::Result {
99+
f: &mut core::fmt::Formatter<'_>,
100+
) -> core::fmt::Result {
99101
let pretty = f.alternate();
100102

101-
let type_name = std::any::type_name::<C>();
103+
let type_name = core::any::type_name::<C>();
102104
let mut handle = f.debug_struct(&format!("PreFabConfig<{}>", type_name));
103105

104106
handle

crates/bimm/src/cache/weights.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
//! # Module / Weight Caches
22
33
use crate::cache::disk::DiskCacheConfig;
4+
use alloc::collections::BTreeMap;
5+
use alloc::string::{String, ToString};
6+
use alloc::vec::Vec;
7+
use alloc::{format, vec};
48
use anyhow::bail;
59
use serde::{Deserialize, Serialize};
6-
use std::collections::BTreeMap;
710
use std::path::PathBuf;
811

912
const X25: crc::Crc<u16> = crc::Crc::<u16>::new(&crc::CRC_16_IBM_SDLC);
@@ -197,6 +200,7 @@ impl PretrainedWeightsMap {
197200
#[cfg(test)]
198201
mod tests {
199202
use super::*;
203+
use alloc::string::{String, ToString};
200204

201205
#[test]
202206
fn test_static_descriptor_to_descriptor() {

crates/bimm/src/compat/conv_shape.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//!
33
//! Utilities for computing the output shape of convolution operations.
44
5+
use alloc::vec::Vec;
6+
57
/// Predict the output size of a 1D convolution operation.
68
///
79
/// ```text

crates/bimm/src/compat/ops.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//! [`Tensor`] ops.
2+
3+
use alloc::vec;
4+
use alloc::vec::Vec;
25
use burn::prelude::{Backend, Tensor};
36
use std::f64;
47

crates/bimm/src/layers/drop/drop_block.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ use crate::layers::drop::size_config::SizeConfig;
77
use crate::utility::burn::kernels;
88
use crate::utility::burn::noise::NoiseConfig;
99
use crate::utility::probability::expect_probability;
10+
use alloc::format;
1011
use bimm_contracts::unpack_shape_contract;
1112
use burn::config::Config;
1213
use burn::module::{Content, Module, ModuleDisplay, ModuleDisplayDefault};
1314
use burn::prelude::{Backend, Float, Tensor};
1415
use burn::tensor::module::max_pool2d;
1516
use burn::tensor::{DType, Distribution};
17+
use core::ops::Range;
1618
use serde::{Deserialize, Serialize};
17-
use std::ops::Range;
1819

1920
/// Configuration for `DropBlock`.
2021
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@@ -224,7 +225,7 @@ impl DropBlockOptions {
224225
let [kh, kw] = self.kernel;
225226
let kh = kh.resolve(h);
226227
let kw = kw.resolve(w);
227-
[std::cmp::min(h, kh), std::cmp::min(w, kw)]
228+
[core::cmp::min(h, kh), core::cmp::min(w, kw)]
228229
}
229230

230231
/// Compute the adjusted gamma rate.

crates/bimm/src/layers/drop/rate_table.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Common rate table for `DropPath` regularization.
2+
23
use crate::compat::ops::float_vec_linspace;
4+
use alloc::vec::Vec;
35

46
/// Computes a progressive incremental path drop rate for stochastic depth.
57
///
@@ -139,6 +141,7 @@ mod tests {
139141
use super::*;
140142
use crate::layers::drop::rate_table::progressive_dpr;
141143
use crate::testing::assert_close_to_vec;
144+
use alloc::vec;
142145
use hamcrest::prelude::*;
143146

144147
#[test]

0 commit comments

Comments
 (0)