diff --git a/candle-pyo3/src/lib.rs b/candle-pyo3/src/lib.rs index 06d682cf68..0da2c70028 100644 --- a/candle-pyo3/src/lib.rs +++ b/candle-pyo3/src/lib.rs @@ -1591,7 +1591,7 @@ fn candle_functional_m(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> } #[cfg(feature = "onnx")] -fn candle_onnx_m(_py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn candle_onnx_m(_py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { use onnx::{PyONNXModel, PyONNXTensorDescriptor}; m.add_class::()?; m.add_class::()?; @@ -1608,9 +1608,9 @@ fn candle(py: Python<'_>, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_submodule(&nn)?; #[cfg(feature = "onnx")] { - let onnx = PyModule::new(py, "onnx")?; - candle_onnx_m(py, onnx)?; - m.add_submodule(onnx)?; + let onnx = PyModule::new_bound(py, "onnx")?; + candle_onnx_m(py, &onnx)?; + m.add_submodule(&onnx)?; } m.add_class::()?; m.add_class::()?; diff --git a/candle-pyo3/src/onnx.rs b/candle-pyo3/src/onnx.rs index b9a0eb2272..a2e9a087b1 100644 --- a/candle-pyo3/src/onnx.rs +++ b/candle-pyo3/src/onnx.rs @@ -39,7 +39,7 @@ impl PyONNXTensorDescriptor { /// The shape of the tensor. /// &RETURNS&: Tuple[Union[int,str,Any]] fn shape(&self, py: Python) -> PyResult> { - let shape = PyList::empty(py); + let shape = PyList::empty_bound(py); if let Some(d) = &self.0.shape { for dim in d.dim.iter() { if let Some(value) = &dim.value {