Skip to content

Commit c8aeb38

Browse files
committed
examples: mnist-rs: bump version of burn
1 parent 47e51fa commit c8aeb38

5 files changed

Lines changed: 14 additions & 13 deletions

File tree

examples/mnist-rs/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
CROSS_COMPILE_HOST ?= aarch64-linux-gnu-
2121
CROSS_COMPILE_TA ?= aarch64-linux-gnu-
2222
TARGET_HOST ?= aarch64-unknown-linux-gnu
23-
TARGET_TA ?= aarch64-unknown-linux-gnu
23+
TARGET_TA := aarch64-unknown-none
2424
FEATURES ?=
2525
CARGO_FLAGS ?=
26-
2726
.PHONY: host ta all clean
2827

2928
all: toolchain host ta

examples/mnist-rs/ta/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ optee-utee-build = { path = "../../../crates/optee-utee-build" }
3939
proto = { path = "../proto" }
4040

4141
bytemuck = { version = "1.21.0", features = ["min_const_generics"] }
42-
burn = { version = "0.17", default-features = false, features = ["ndarray", "autodiff"] }
42+
burn = { version = "0.21", default-features = false, features = ["ndarray", "autodiff"] }
4343
spin = "0.9.8"
4444
serde = { version = "1.0.218", default-features = false, features = ["derive"] }
4545
serde_json = { version = "1.0.139", default-features = false, features = ["alloc"] }

examples/mnist-rs/ta/inference/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
UUID ?= $(shell cat "./uuid.txt")
1919
NAME := inference
2020

21-
TARGET ?= aarch64-unknown-linux-gnu
21+
TARGET ?= aarch64-unknown-none
2222
CROSS_COMPILE ?= aarch64-linux-gnu-
2323
OBJCOPY := $(CROSS_COMPILE)objcopy
2424
# Configure the linker to use GCC, which works on both cross-compilation and ARM machines
2525
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
2626
# fix for the error: "unwinding panics are not supported without std" reported by clippy
27-
RUSTFLAGS := -C panic=abort
27+
RUSTFLAGS := -C panic=abort -C relocation-model=pic
28+
CARGO_FLAGS ?=
2829

2930
TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
3031
SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
@@ -34,10 +35,10 @@ all: clippy ta strip sign
3435

3536
clippy:
3637
@cargo fmt
37-
@RUSTFLAGS="$(RUSTFLAGS)" cargo clippy --target $(TARGET) -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::panic
38+
@RUSTFLAGS="$(RUSTFLAGS)" cargo clippy $(CARGO_FLAGS) --target $(TARGET) -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::panic
3839

3940
ta: clippy
40-
@RUSTFLAGS="$(RUSTFLAGS)" cargo build --target $(TARGET) --release --config $(LINKER_CFG)
41+
@RUSTFLAGS="$(RUSTFLAGS)" cargo build $(CARGO_FLAGS) --target $(TARGET) --release --config $(LINKER_CFG)
4142

4243
strip: ta
4344
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/stripped_$(NAME)

examples/mnist-rs/ta/train/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
UUID ?= $(shell cat "./uuid.txt")
1919
NAME := train
2020

21-
TARGET ?= aarch64-unknown-linux-gnu
21+
TARGET ?= aarch64-unknown-none
2222
CROSS_COMPILE ?= aarch64-linux-gnu-
2323
OBJCOPY := $(CROSS_COMPILE)objcopy
2424
# Configure the linker to use GCC, which works on both cross-compilation and ARM machines
2525
LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\"
2626
# fix for the error: "unwinding panics are not supported without std" reported by clippy
27-
RUSTFLAGS := -C panic=abort
27+
RUSTFLAGS := -C panic=abort -C relocation-model=pic
28+
CARGO_FLAGS ?=
2829

2930
TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem
3031
SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py
@@ -34,10 +35,10 @@ all: clippy ta strip sign
3435

3536
clippy:
3637
@cargo fmt
37-
@RUSTFLAGS="$(RUSTFLAGS)" cargo clippy --target $(TARGET) -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::panic
38+
@RUSTFLAGS="$(RUSTFLAGS)" cargo clippy $(CARGO_FLAGS) --target $(TARGET) -- -D warnings -D clippy::unwrap_used -D clippy::expect_used -D clippy::panic
3839

3940
ta: clippy
40-
@RUSTFLAGS="$(RUSTFLAGS)" cargo build --target $(TARGET) --release --config $(LINKER_CFG)
41+
@RUSTFLAGS="$(RUSTFLAGS)" cargo build $(CARGO_FLAGS) --target $(TARGET) --release --config $(LINKER_CFG)
4142

4243
strip: ta
4344
@$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/stripped_$(NAME)

examples/mnist-rs/ta/train/src/trainer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<B: AutodiffBackend> Trainer<B> {
3838
pub fn new(device: B::Device, lr: f64) -> Self {
3939
let mut seed = [0_u8; 8];
4040
optee_utee::Random::generate(seed.as_mut_slice());
41-
B::seed(u64::from_le_bytes(seed));
41+
B::seed(&device, u64::from_le_bytes(seed));
4242

4343
Self {
4444
optim: AdamConfig::new().init(),
@@ -106,7 +106,7 @@ impl<B: AutodiffBackend> Trainer<B> {
106106
// to https://github.com/tracel-ai/burn/blob/v0.16.0/crates/burn-no-std-test for
107107
// details.
108108
fn accuracy<B: Backend>(output: Tensor<B, 2>, targets: Tensor<B, 1, Int>) -> f32 {
109-
let predictions = output.argmax(1).squeeze(1);
109+
let predictions = output.argmax(1).squeeze();
110110
let num_predictions: usize = targets.dims().iter().product();
111111
let num_corrects = predictions.equal(targets).int().sum().into_scalar();
112112

0 commit comments

Comments
 (0)