Skip to main content

SymTensor

Struct SymTensor 

Source
pub struct SymTensor {
    pub node_id: usize,
    pub graph: Rc<RefCell<Graph>>,
    pub dtype: DtypeRepr,
    pub shape: Shape,
}
Expand description

A symbolic tensor handle. Every layer operation on a SymTensor records itself in the shared Graph and returns a new SymTensor pointing to the new node. Cloning is cheap — it shares the graph via Rc.

Fields§

§node_id: usize

This tensor’s node index in graph.

§graph: Rc<RefCell<Graph>>

The shared graph this tensor’s operations record into.

§dtype: DtypeRepr

This tensor’s dtype.

§shape: Shape

Output shape of this tensor. None in a slot means a dynamic/unknown dimension (e.g. the batch axis).

Implementations§

Source§

impl SymTensor

Source

pub fn input(dtype: DtypeRepr, shape: Shape) -> (Self, Rc<RefCell<Graph>>)

Create an input placeholder, returning both the tensor and the shared graph handle. Keep the graph handle to inspect the result after tracing.

Use None for dynamic dimensions (e.g. the batch axis):

SymTensor::input(DtypeRepr::F32, vec![None, Some(784)])
Source

pub fn rank(&self) -> usize

Number of dimensions of this tensor.

Source

pub fn record_custom( &self, data: CustomData, other_inputs: &[&SymTensor], dtype: Option<DtypeRepr>, ) -> Self

Record a custom op whose output shape is determined by CustomOp::infer_output_shape.

self is the primary (first) input. Pass additional inputs via other_inputs. Pass dtype to override the output element type; defaults to the primary input’s dtype.

Trait Implementations§

Source§

impl Clone for SymTensor

Source§

fn clone(&self) -> SymTensor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for AvgPool1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for AvgPool2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for AvgPool3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for BatchNorm1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for BatchNorm2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for BatchNorm3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Celu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for CircularPad1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for CircularPad2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for CircularPad3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ConstantPad1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ConstantPad2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ConstantPad3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for Conv1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for Conv2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for Conv3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Elu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype> Layer<SymTensor> for Flatten<D, SymTensor, SymTensor>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Gelu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for GroupNorm<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Hardshrink<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Hardsigmoid<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Hardswish<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Hardtanh<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for InstanceNorm1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for InstanceNorm2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for InstanceNorm3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for LayerNorm<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for LeakyRelu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for Linear<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Logsigmoid<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for LpPool1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for LpPool2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for LpPool3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for MaxPool1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for MaxPool2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for MaxPool3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Mish<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ReflectionPad1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ReflectionPad2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ReflectionPad3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for Relu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Relu6<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ReplicationPad1d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ReplicationPad2d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for ReplicationPad3d<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> Layer<SymTensor> for RmsNorm<D, SymTensor, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Selu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Sigmoid<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Silu<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Softmax<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Softplus<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Softshrink<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Softsign<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Tanh<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Tanhshrink<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Float, const RANK: usize> Layer<SymTensor> for Threshold<D, SymTensor, RANK>

Source§

type Output = SymTensor

This layer’s output type.
Source§

fn call(&self, input: SymTensor) -> SymTensor

Applies this layer to input.
Source§

impl<D: Dtype, const RANK: usize> RankedTensor<D, RANK> for SymTensor

Source§

const SHAPE: [usize; RANK]

This tensor’s shape.
Source§

impl<D: Dtype, const RANK: usize> Tensor<D, RANK> for SymTensor

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.