pub struct PyTree<T> { /* private fields */ }
Expand description
A Rust wrapper around A PyTorch pytree, which can be serialized and sent across the wire. https://github.com/pytorch/pytorch/blob/main/torch/utils/_pytree.py
Implementations§
Source§impl<T> PyTree<T>
impl<T> PyTree<T>
pub fn is_leaf(&self) -> bool
pub fn into_leaf(self) -> Option<T>
pub fn leaves(&self) -> &[T]
pub fn into_leaves(self) -> Vec<T>
pub fn for_each<F>(&self, func: F)
pub fn iter<'a>(&'a self) -> Iter<'a, T>
pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T>
Sourcepub fn into_map<U, F>(self, func: F) -> PyTree<U>where
F: FnMut(T) -> U,
pub fn into_map<U, F>(self, func: F) -> PyTree<U>where
F: FnMut(T) -> U,
Map leaf values with the given func.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for PyTree<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for PyTree<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'a, T: FromPyObject<'a>> FromPyObject<'a> for PyTree<T>
Deserialize from a PyObject
.
impl<'a, T: FromPyObject<'a>> FromPyObject<'a> for PyTree<T>
Deserialize from a PyObject
.
Source§fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult<Self>
fn extract_bound(ob: &Bound<'a, PyAny>) -> PyResult<Self>
Source§impl<'a, 'py, T> IntoPyObject<'py> for &'a PyTree<T>where
&'a T: IntoPyObject<'py>,
T: 'a,
impl<'a, 'py, T> IntoPyObject<'py> for &'a PyTree<T>where
&'a T: IntoPyObject<'py>,
T: 'a,
Source§impl<'py, T> IntoPyObject<'py> for PyTree<T>where
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObject<'py> for PyTree<T>where
T: IntoPyObject<'py>,
Source§impl<'a, 'py, T> TryIntoPyObjectUnsafe<'py, PyAny> for &'a PyTree<T>where
&'a T: TryIntoPyObjectUnsafe<'py, PyAny>,
T: 'a,
Serialize into a PyObject
.
impl<'a, 'py, T> TryIntoPyObjectUnsafe<'py, PyAny> for &'a PyTree<T>where
&'a T: TryIntoPyObjectUnsafe<'py, PyAny>,
T: 'a,
Serialize into a PyObject
.
unsafe fn try_to_object_unsafe( self, py: Python<'py>, ) -> PyResult<Bound<'py, PyAny>>
Auto Trait Implementations§
impl<T> Freeze for PyTree<T>
impl<T> RefUnwindSafe for PyTree<T>where
T: RefUnwindSafe,
impl<T> Send for PyTree<T>where
T: Send,
impl<T> Sync for PyTree<T>where
T: Sync,
impl<T> Unpin for PyTree<T>where
T: Unpin,
impl<T> UnwindSafe for PyTree<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
Converts
self
into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
Converts
self
into an owned Python object, dropping type information and unbinding it
from the 'py
lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
Converts
self
into a Python object. Read more