pub enum TensorOp {
Show 34 variants
Input {
name: String,
},
Constant {
value_cid: String,
},
MatMul,
Add,
Mul,
Sub,
Div,
Einsum {
subscripts: String,
},
Reshape {
shape: Vec<i64>,
},
Transpose {
axes: Vec<usize>,
},
ReduceSum {
axes: Vec<usize>,
keepdims: bool,
},
ReduceMean {
axes: Vec<usize>,
keepdims: bool,
},
ReLU,
Tanh,
Sigmoid,
GELU,
Softmax {
axis: i64,
},
LayerNorm {
normalized_shape: Vec<usize>,
eps: f64,
},
BatchNorm {
eps: f64,
momentum: f64,
},
Dropout {
p: f64,
},
Exp,
Log,
Pow {
exponent: f64,
},
Sqrt,
Concat {
axis: usize,
},
Split {
axis: usize,
sections: Vec<usize>,
},
Gather {
axis: usize,
},
Scatter {
axis: usize,
},
Slice {
start: Vec<i64>,
end: Vec<i64>,
strides: Vec<i64>,
},
Pad {
padding: Vec<(usize, usize)>,
mode: String,
},
FusedLinear,
FusedAddReLU,
FusedBatchNormReLU {
eps: f64,
momentum: f64,
},
FusedLayerNormDropout {
normalized_shape: Vec<usize>,
eps: f64,
dropout_p: f64,
},
}Expand description
Tensor operation types
Variants§
Input
Input placeholder
Constant
Constant tensor
MatMul
Matrix multiplication
Add
Element-wise addition
Mul
Element-wise multiplication
Sub
Element-wise subtraction
Div
Element-wise division
Einsum
Einsum operation with subscript notation
Reshape
Reshape operation
Transpose
Transpose operation
ReduceSum
Reduce sum along axes
ReduceMean
Reduce mean along axes
ReLU
Activation: ReLU
Tanh
Activation: Tanh
Sigmoid
Activation: Sigmoid
GELU
Activation: GELU (Gaussian Error Linear Unit)
Softmax
Activation: Softmax along axis
LayerNorm
Layer normalization
BatchNorm
Batch normalization
Dropout
Dropout (training mode)
Exp
Element-wise exponential
Log
Element-wise logarithm
Pow
Element-wise power
Sqrt
Element-wise square root
Concat
Concatenate tensors along axis
Split
Split tensor along axis
Gather
Gather elements along axis
Scatter
Scatter elements along axis
Slice
Slice tensor
Pad
Pad tensor
FusedLinear
Fused MatMul + Add (common in linear layers)
FusedAddReLU
Fused Add + ReLU
FusedBatchNormReLU
Fused BatchNorm + ReLU
FusedLayerNormDropout
Fused LayerNorm + Dropout
Implementations§
Source§impl TensorOp
impl TensorOp
Sourcepub fn num_inputs(&self) -> usize
pub fn num_inputs(&self) -> usize
Get the number of inputs required by this operation
Sourcepub fn infer_output_shape(
&self,
input_shapes: &[Vec<usize>],
) -> Result<Vec<usize>, GraphError>
pub fn infer_output_shape( &self, input_shapes: &[Vec<usize>], ) -> Result<Vec<usize>, GraphError>
Infer output shape from input shapes
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TensorOp
impl<'de> Deserialize<'de> for TensorOp
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>,
impl StructuralPartialEq for TensorOp
Auto Trait Implementations§
impl Freeze for TensorOp
impl RefUnwindSafe for TensorOp
impl Send for TensorOp
impl Sync for TensorOp
impl Unpin for TensorOp
impl UnwindSafe for TensorOp
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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>
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