Skip to content

Commit 81d66c7

Browse files
committed
ci: add windows/macos runners and no_std verification
1 parent da403ca commit 81d66c7

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

.github/workflows/test.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,27 @@ on:
1717
- 'tests/**/*'
1818
jobs:
1919
test:
20-
name: Run tests
21-
runs-on: ${{ matrix.platform.os }}
20+
name: test (${{ matrix.os }})
21+
runs-on: ${{ matrix.os }}
2222
strategy:
2323
fail-fast: false
2424
matrix:
25-
platform:
26-
- os: ubuntu-latest
25+
os: [ubuntu-latest, windows-latest, macos-latest]
2726
steps:
2827
- uses: actions/checkout@v5
2928
- name: Install stable Rust toolchain
3029
uses: dtolnay/rust-toolchain@stable
31-
with:
32-
toolchain: stable
3330
- uses: Swatinem/rust-cache@v2
3431
- name: Run tests
35-
run: |
36-
cargo test --verbose
32+
run: cargo test --verbose
33+
34+
no-std:
35+
name: check (no_std + libm)
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v5
39+
- name: Install stable Rust toolchain
40+
uses: dtolnay/rust-toolchain@stable
41+
- uses: Swatinem/rust-cache@v2
42+
- name: Build
43+
run: cargo check --verbose --no-default-features --features libm

src/default_predictor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn input_layer3(features: &[f32], output: &mut [i16]) {
192192
}
193193

194194
// note: transposed, no ReLU or bias
195-
output[(ox * CHANNELS) + oc] = (ic * 32768.0).round().clamp(-32768.0, 32767.0) as i16;
195+
output[(ox * CHANNELS) + oc] = crate::util::libm::roundf(ic * 32768.0).clamp(-32768.0, 32767.0) as i16;
196196
}
197197
}
198198
}

src/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ pub mod libm {
2020
pub fn expf(f: f32) -> f32 {
2121
f.exp()
2222
}
23+
#[inline(always)]
24+
pub fn roundf(f: f32) -> f32 {
25+
f.round()
26+
}
2327
}

0 commit comments

Comments
 (0)