Skip to content

Compile the DeepFilterNet WASM module with more performance #5

Description

@sevagh

Hello,

Thanks for this project - it helped me when exploring DeepFilterNet inference in WebAssembly. I followed your contents on that repo: Rikorose/DeepFilterNet#430, Rikorose/DeepFilterNet#472

I took a look at tract (https://github.com/sonos/tract) and it has WASM SIMD128 support for some of its operators e.g. MatMul (which will boost performance).

If you modify libDF/Cargo.toml to add this:

[profile.release]
opt-level = 3          # or "z"
lto = "fat"            # or "thin"
codegen-units = 1
panic = "abort"

[package.metadata.wasm-pack.profile.dev]
wasm-opt = ['--enable-simd', '-O4']
[package.metadata.wasm-pack.profile.profiling]
wasm-opt = ['--enable-simd', '-O4']
[package.metadata.wasm-pack.profile.release]
wasm-opt = ['--enable-simd', '-O4']

And in build_wasm_package.sh:

cd ./libDF/

# Set Rust flags to enable WASM SIMD instructions and optimize for size.
export RUSTFLAGS="-C target-feature=+simd128 -C opt-level=z -C link-arg=-s"

wasm-pack build --target web --no-typescript --features "wasm"

You may notice better performance in your web demo!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions