Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASI ML Prototype #3

Closed
wants to merge 26 commits into from

Conversation

yordanmadzhunkov
Copy link
Collaborator

In order to test the prototype you should use this commands or make some changes based on them

I will use the following variable for the location of spin repo on your system

export SPIN_REPO=...

Compile the core wasi test, this will create a WASM files to be loaded and executed by the host test program. This step should also download mobilenet files and 2 sample images and save them in ${SPIN_REPO}/target/test-programs/imagenet

cd ${SPIN_REPO}/crates/core/tests/core-wasi-test/ 
echo "COMPILING CORE-WASM-TEST" 
cargo build 

Make sure that your output is compiled and the WASM file is up to date

ls -l ${SPIN_REPO}/target/wasm32-wasi/debug/core-wasi-test.wasm 
ls -l ${SPIN_REPO}/target/test-programs/imagenet

Copy the wasm file to test programs, from where it will be loaded and executed by test host program

cp ${SPIN_REPO}/target/wasm32-wasi/debug/core-wasi-test.wasm ${SPIN_REPO}/target/test-programs/core-wasi-test.wasm 

Compile the host and run the tests with showing the output

cd ${SPIN_REPO}/crates/core/
echo "COMPILING HOST"
cargo test -- --show-output

Note, that the protorype backend uses openvino, so you need to have Openvino installed on your system and in order the backend to use it needs to find it in the path. I am using env variable. More info can be found openvino_finder

export OPENVINO_INSTALL_DIR=/nix/store/fsi4q6nh7vvg3jgg835hpqdwkswjpbbl-openvino-2023.0.0/
---- test_host_component_imagenet_openvino_cpu stdout ----
imagenet_path = "/home/yordan/code/repos/spin/crates/core/../../target/test-programs/imagenet"
module_path = "/home/yordan/code/repos/spin/crates/core/../../target/test-programs/core-wasi-test.wasm"
Loaded model from xml 140.16 kB `fs::read` took 1.69 ms
Loaded weigths 13.31 MB `fs::read` took 66.93 ms
---- ExecutionTarget::Cpu ----
Loaded graph with ID: Graph { handle: Resource { handle: 0 } } `graph::load` took 68.46 ms
Created context with ID: GraphExecutionContext { handle: Resource { handle: 0 } } `Graph::init_execution_context` took 216.77 ms
Created tensor with ID: Tensor { handle: Resource { handle: 0 } } `Tensor::new` took 2.82 ms
Input set with ID: () `GraphExecutionContext::set_input` took 291.11 µs
Executed graph inference. `GraphExecutionContext::compute` took 3.13 ms
Obtaining output `GraphExecutionContext::get_output` took 96.30 µs
Copying data from tensor. `Tensor::data+dimensions+type` took 140.48 µs
---- test_host_component_imagenet_openvino_gpu stdout ----
imagenet_path = "/home/yordan/code/repos/spin/crates/core/../../target/test-programs/imagenet"
module_path = "/home/yordan/code/repos/spin/crates/core/../../target/test-programs/core-wasi-test.wasm"
Loaded model from xml 140.16 kB `fs::read` took 1.01 ms
Loaded weigths 13.31 MB `fs::read` took 69.83 ms
---- ExecutionTarget::Gpu ----
Loaded graph with ID: Graph { handle: Resource { handle: 0 } } `graph::load` took 70.64 ms
Created context with ID: GraphExecutionContext { handle: Resource { handle: 0 } } `Graph::init_execution_context` took 1121.19 ms
Created tensor with ID: Tensor { handle: Resource { handle: 0 } } `Tensor::new` took 2.66 ms
Input set with ID: () `GraphExecutionContext::set_input` took 120.90 µs
Executed graph inference. `GraphExecutionContext::compute` took 4.18 ms
Obtaining output `GraphExecutionContext::get_output` took 66.98 µs
Copying data from tensor. `Tensor::data+dimensions+type` took 67.38 µs


@yordanmadzhunkov yordanmadzhunkov self-assigned this Jun 17, 2024
@yordanmadzhunkov yordanmadzhunkov changed the base branch from main to blocksense June 17, 2024 11:12
@yordanmadzhunkov yordanmadzhunkov force-pushed the feat/yordan/wasi_ml_prototype branch from fdc06a8 to d872714 Compare June 17, 2024 11:15
@yordanmadzhunkov yordanmadzhunkov force-pushed the feat/yordan/wasi_ml_prototype branch from 594e63f to a1b7461 Compare June 25, 2024 14:41
Copy link
Collaborator

@melatron melatron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work, only to nits -

  1. Remove the hello component
  2. Move your changes to another folder so that we don't mess with current spin tests (.wit and changes inside core-wasi-test). Maybe we can just add the integration test to integration_test.rs

@yordanmadzhunkov
Copy link
Collaborator Author

Good work, only to nits -

1. Remove the hello component

2. Move your changes to another folder so that we don't mess with current spin tests (`.wit` and changes inside core-wasi-test). Maybe we can just add the integration test to integration_test.rs

Done

@yordanmadzhunkov yordanmadzhunkov deleted the feat/yordan/wasi_ml_prototype branch July 1, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants