stdlib/tensorView source ↗
tensor
27 items · generated by scribe fromstdlib/tensor.fd· synced 2026-11-15
Contents
- zeros (function)
- ones (function)
- filled (function)
- from_vec (function)
- get (function)
- set (function)
- shape (function)
- ndim (function)
- size (function)
- reshape (function)
- transpose (function)
- add (function)
- sub (function)
- mul (function)
- scale (function)
- matmul (function)
- dot (function)
- sum (function)
- mean (function)
- max (function)
- min (function)
- relu (function)
- sigmoid (function)
- softmax (function)
- to_str (function)
- to_json (function)
- clone (function)
zeros
Create a tensor of zeros with the given shape. shape is a Vec
pub fn zeros(shape: Vec<i64>) -> Tensor {Parameters:
shape:Vec<i64>
Returns: Tensor
Defined at line 13
ones
Create a tensor of ones with the given shape.
pub fn ones(shape: Vec<i64>) -> Tensor {Parameters:
shape:Vec<i64>
Returns: Tensor
Defined at line 18
filled
Create a tensor filled with a constant value.
pub fn filled(shape: Vec<i64>, value: f64) -> Tensor {Parameters:
shape:Vec<i64>value:f64
Returns: Tensor
Defined at line 23
from_vec
Create a tensor from a flat Vec with a given shape.
pub fn from_vec(data: Vec<i64>, shape: Vec<i64>) -> Tensor {Parameters:
data:Vec<i64>shape:Vec<i64>
Returns: Tensor
Defined at line 28
get
Get an element by multi-index. indices is a Vec
pub fn get(t: Tensor, indices: Vec<i64>) -> f64 {Parameters:
t:Tensorindices:Vec<i64>
Returns: f64
Defined at line 33
set
Set an element by multi-index.
pub fn set(t: Tensor, indices: Vec<i64>, value: f64) -> void {Parameters:
t:Tensorindices:Vec<i64>value:f64
Returns: void
Defined at line 38
shape
Get the shape as a Vec
pub fn shape(t: Tensor) -> Vec<i64> {Parameters:
t:Tensor
Returns: Vec<i64>
Defined at line 43
ndim
Get the number of dimensions.
pub fn ndim(t: Tensor) -> i64 {Parameters:
t:Tensor
Returns: i64
Defined at line 48
size
Get the total number of elements.
pub fn size(t: Tensor) -> i64 {Parameters:
t:Tensor
Returns: i64
Defined at line 53
reshape
Reshape the tensor (total size must be preserved).
pub fn reshape(t: Tensor, new_shape: Vec<i64>) -> Tensor {Parameters:
t:Tensornew_shape:Vec<i64>
Returns: Tensor
Defined at line 58
transpose
Transpose the tensor (reverse all axes).
pub fn transpose(t: Tensor) -> Tensor {Parameters:
t:Tensor
Returns: Tensor
Defined at line 63
add
Elementwise addition.
pub fn add(a: Tensor, b: Tensor) -> Tensor {Parameters:
a:Tensorb:Tensor
Returns: Tensor
Defined at line 68
sub
Elementwise subtraction.
pub fn sub(a: Tensor, b: Tensor) -> Tensor {Parameters:
a:Tensorb:Tensor
Returns: Tensor
Defined at line 73
mul
Elementwise multiplication (Hadamard product).
pub fn mul(a: Tensor, b: Tensor) -> Tensor {Parameters:
a:Tensorb:Tensor
Returns: Tensor
Defined at line 78
scale
Scale by a scalar.
pub fn scale(t: Tensor, s: f64) -> Tensor {Parameters:
t:Tensors:f64
Returns: Tensor
Defined at line 83
matmul
Matrix multiplication: (M, K) @ (K, N) -> (M, N).
pub fn matmul(a: Tensor, b: Tensor) -> Tensor {Parameters:
a:Tensorb:Tensor
Returns: Tensor
Defined at line 88
dot
Dot product of 1D vectors.
pub fn dot(a: Tensor, b: Tensor) -> f64 {Parameters:
a:Tensorb:Tensor
Returns: f64
Defined at line 93
sum
Sum of all elements.
pub fn sum(t: Tensor) -> f64 {Parameters:
t:Tensor
Returns: f64
Defined at line 98
mean
Mean of all elements.
pub fn mean(t: Tensor) -> f64 {Parameters:
t:Tensor
Returns: f64
Defined at line 103
max
Maximum element.
pub fn max(t: Tensor) -> f64 {Parameters:
t:Tensor
Returns: f64
Defined at line 108
min
Minimum element.
pub fn min(t: Tensor) -> f64 {Parameters:
t:Tensor
Returns: f64
Defined at line 113
relu
ReLU activation: max(0, x).
pub fn relu(t: Tensor) -> Tensor {Parameters:
t:Tensor
Returns: Tensor
Defined at line 118
sigmoid
Sigmoid activation: 1 / (1 + e^-x).
pub fn sigmoid(t: Tensor) -> Tensor {Parameters:
t:Tensor
Returns: Tensor
Defined at line 123
softmax
Softmax along the last axis.
pub fn softmax(t: Tensor) -> Tensor {Parameters:
t:Tensor
Returns: Tensor
Defined at line 128
to_str
Convert tensor to a readable string representation.
pub fn to_str(t: Tensor) -> str {Parameters:
t:Tensor
Returns: str
Defined at line 133
to_json
Convert tensor to JSON (shape + flat data).
pub fn to_json(t: Tensor) -> str {Parameters:
t:Tensor
Returns: str
Defined at line 138
clone
Clone a tensor.
pub fn clone(t: Tensor) -> Tensor {Parameters:
t:Tensor
Returns: Tensor
Defined at line 143
Generated by scribe, the Fides documentation generator