Demo with wgpu

This commit is contained in:
nathaniel 2023-08-23 14:16:29 -04:00
parent 89eb248b88
commit 1720eb188c
3 changed files with 5 additions and 2 deletions

View File

@ -15,6 +15,7 @@ default = []
[dependencies]
burn = {path = "../../burn", default-features = false}
burn-ndarray = {path = "../../burn-ndarray", default-features = false}
burn-wgpu = {path = "../../burn-wgpu", default-features = false}
serde = {workspace = true}
wasm-bindgen = "0.2.87"

View File

@ -10,7 +10,7 @@ then
fi
# Set optimization flags
export RUSTFLAGS="-C lto=fat -C embed-bitcode=yes -C codegen-units=1 -C opt-level=3"
export RUSTFLAGS="-C lto=fat -C embed-bitcode=yes -C codegen-units=1 -C opt-level=3 --cfg=web_sys_unstable_apis"
# Run wasm pack tool to build JS wrapper files and copy wasm to pkg directory.
mkdir -p pkg

View File

@ -4,8 +4,10 @@ use burn::record::BinBytesRecorder;
use burn::record::FullPrecisionSettings;
use burn::record::Recorder;
use burn_ndarray::NdArrayBackend;
use burn_wgpu::WgpuBackend;
pub type Backend = NdArrayBackend<f32>;
pub type Backend = WgpuBackend<burn_wgpu::AutoGraphicsApi, f32, i32>;
// pub type Backend = NdArrayBackend<f32>;
static STATE_ENCODED: &[u8] = include_bytes!("../model.bin");