diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3f36e9f6..37bd93c5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -40,9 +40,9 @@ jobs: python-version: '3.10.6' cache: 'pip' - run: pip install -r requirements.txt - - name: Setup + - name: Install wasm-pack run: | - cargo install wasm-pack + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build run: cargo build - name: Run tests diff --git a/crates/ratchet-core/src/tensor.rs b/crates/ratchet-core/src/tensor.rs index 7ffe2fe3..e51454bc 100644 --- a/crates/ratchet-core/src/tensor.rs +++ b/crates/ratchet-core/src/tensor.rs @@ -426,46 +426,49 @@ mod tests { Ok(()) } - #[test] - fn test_pyo3() -> anyhow::Result<()> { - let cpu_device = Device::request_device(DeviceRequest::CPU)?; - let a = Tensor::randn::(shape![1024, 1024], cpu_device.clone()); - let b = Tensor::randn::(shape![1024, 1024], cpu_device.clone()); - - let ground: anyhow::Result = Python::with_gil(|py| { - let prg = PyModule::from_code( - py, - r#" -import torch - -def matmul(a, b): - return torch.matmul(torch.from_numpy(a), torch.from_numpy(b)).numpy() - "#, - "x.py", - "x", - )?; - - let result = prg - .getattr("matmul")? - .call1((a.clone().to_py::(py), b.clone().to_py::(py)))? - .extract::<&PyArrayDyn>()?; - Ok(Tensor::from(result)) - }); - println!("\nTORCH: {:#?}", ground); - - println!("\nA: {:#?}", a); - println!("\nB: {:#?}", b); - - let gpu_device = Device::request_device(DeviceRequest::GPU)?; - let a = a.to(gpu_device.clone())?; - let b = b.to(gpu_device)?; - - let c = a.matmul(&b)?; - c.resolve()?; - - let our_result = c.to(cpu_device)?; - println!("\nOURS: {:#?}", our_result); - - Ok(()) - } + /* + + #[test] + fn test_pyo3() -> anyhow::Result<()> { + let cpu_device = Device::request_device(DeviceRequest::CPU)?; + let a = Tensor::randn::(shape![1024, 1024], cpu_device.clone()); + let b = Tensor::randn::(shape![1024, 1024], cpu_device.clone()); + + let ground: anyhow::Result = Python::with_gil(|py| { + let prg = PyModule::from_code( + py, + r#" + import torch + + def matmul(a, b): + return torch.matmul(torch.from_numpy(a), torch.from_numpy(b)).numpy() + "#, + "x.py", + "x", + )?; + + let result = prg + .getattr("matmul")? + .call1((a.clone().to_py::(py), b.clone().to_py::(py)))? + .extract::<&PyArrayDyn>()?; + Ok(Tensor::from(result)) + }); + println!("\nTORCH: {:#?}", ground); + + println!("\nA: {:#?}", a); + println!("\nB: {:#?}", b); + + let gpu_device = Device::request_device(DeviceRequest::GPU)?; + let a = a.to(gpu_device.clone())?; + let b = b.to(gpu_device)?; + + let c = a.matmul(&b)?; + c.resolve()?; + + let our_result = c.to(cpu_device)?; + println!("\nOURS: {:#?}", our_result); + + Ok(()) + } + */ }