burn_backend/tensor/ops/
autodiff.rs

1use crate::{
2    AutodiffBackend,
3    tensor::{BasicOps, TensorKind},
4};
5
6/// Trait that list all operations that can be applied on all tensors on an autodiff backend.
7///
8/// # Warnings
9///
10/// This is an internal trait, use the public API provided by the
11#[cfg_attr(doc, doc = crate::doc_tensor!())]
12#[cfg_attr(not(doc), doc = "`Tensor`")]
13/// struct.
14pub trait BasicAutodiffOps<B: AutodiffBackend>: BasicOps<B> + BasicOps<B::InnerBackend> {
15    /// Inner primitive tensor.
16    type InnerKind: BasicOps<B::InnerBackend>;
17
18    /// Returns the inner tensor without the autodiff information.
19    ///
20    /// # Remarks
21    ///
22    /// This is a low-level function used internally by the library to call different backend functions
23    /// with static dispatch. It is not designed for direct usage by users, and not recommended to import
24    /// or use this function directly.
25    ///
26    /// Users should prefer the
27    #[cfg_attr(doc, doc = crate::doc_tensor!("inner"))]
28    #[cfg_attr(not(doc), doc = "`Tensor::inner`")]
29    /// function, which is more high-level and designed for public use.
30    fn inner(
31        tensor: <Self as TensorKind<B>>::Primitive,
32    ) -> <Self::InnerKind as TensorKind<B::InnerBackend>>::Primitive;
33
34    /// Convert a tensor to the autodiff backend.
35    ///
36    /// # Remarks
37    ///
38    /// This is a low-level function used internally by the library to call different backend functions
39    /// with static dispatch. It is not designed for direct usage by users, and not recommended to import
40    /// or use this function directly.
41    ///
42    /// Users should prefer the
43    #[cfg_attr(doc, doc = crate::doc_tensor!("from_inner"))]
44    #[cfg_attr(not(doc), doc = "`Tensor::from_inner`")]
45    /// function, which is more high-level and designed for public use.
46    fn from_inner(
47        inner: <Self::InnerKind as TensorKind<B::InnerBackend>>::Primitive,
48    ) -> <Self as TensorKind<B>>::Primitive;
49}