From 237323c2bcfde1b7f881d2b71e21be27b3f73838 Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Fri, 1 Sep 2023 15:26:18 +0200 Subject: [PATCH] Cleanup the pyo3 setup. (#705) --- Makefile | 16 ++++++++++++---- candle-core/src/device.rs | 1 - candle-pyo3/src/lib.rs | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index cc0a0a36..1c4009b4 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,15 @@ +pyo3-test: + cargo build --profile=release-with-debug --package candle-pyo3 + cp -f ./target/release-with-debug/libcandle.so candle.so + PYTHONPATH=.:$PYTHONPATH python3 candle-pyo3/test.py + +pyo3-test-macos: + cargo build --profile=release-with-debug --package candle-pyo3 + cp -f ./target/release-with-debug/libcandle.dylib candle.so + PYTHONPATH=.:$PYTHONPATH python3 candle-pyo3/test.py + +.PHONY: pyo3-test pyo3-test-macos clean-ptx clean test + clean-ptx: find target -name "*.ptx" -type f -delete echo "" > candle-kernels/src/lib.rs @@ -11,8 +23,4 @@ clean: test: cargo test -pyo3-test: - cargo build --profile=release-with-debug --package candle-pyo3 - python3 candle-pyo3/test.py - all: test diff --git a/candle-core/src/device.rs b/candle-core/src/device.rs index 84716249..c057595f 100644 --- a/candle-core/src/device.rs +++ b/candle-core/src/device.rs @@ -16,7 +16,6 @@ pub enum Device { Cuda(crate::CudaDevice), } -// TODO: Should we back the cpu implementation using the NdArray crate or similar? pub trait NdArray { fn shape(&self) -> Result; diff --git a/candle-pyo3/src/lib.rs b/candle-pyo3/src/lib.rs index 4dd7b3ea..e93f1b17 100644 --- a/candle-pyo3/src/lib.rs +++ b/candle-pyo3/src/lib.rs @@ -470,6 +470,7 @@ fn candle(_py: Python<'_>, m: &PyModule) -> PyResult<()> { m.add_class::()?; m.add("u8", PyDType(DType::U8))?; m.add("u32", PyDType(DType::U32))?; + m.add("i16", PyDType(DType::I64))?; m.add("bf16", PyDType(DType::BF16))?; m.add("f16", PyDType(DType::F16))?; m.add("f32", PyDType(DType::F32))?;