Struct GTensor

Source
pub struct GTensor<const DIMS: usize> { /* private fields */ }
Expand description

A GGML tensor. It uses a const generic for the dimensions.

Implementations§

Source§

impl<const DIMS: usize> GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source

pub fn add<T: AsRef<GTensor<DIMS>>>(&self, rhs: T) -> Self

Add tensor B to tensor A. Returns a new tensor.

a.add(b) or a + b

Invariants

  1. A and B must have the same shape.
  2. Result will have the shape of A.

Example (pseudocode):

let a = [2, 2, 2];
let b = [1, 1, 1];
let result = a.add(b);
assert_eq!(result, [3, 3, 3]);
Source

pub fn sub<T: AsRef<GTensor<DIMS>>>(&self, rhs: T) -> Self

Subtract tensor B from tensor A. Returns a new tensor.

a.sub(b) or a - b

Invariants

  1. A and B must have the same shape.
  2. Result will have the shape of A.

Example (pseudocode):

let a = [3, 3, 3];
let b = [1, 1, 1];
let result = a.div(b);
assert_eq!(result, [2, 2, 2]);
Source

pub fn mul<T: AsRef<GTensor<DIMS>>>(&self, rhs: T) -> Self

Multiply tensor A by tensor B. Returns a new tensor.

Note: This is elementwise multiplication, not matrix multiplication.

a.mul(b) or a * b

Invariants

  1. A and B must have the same shape.
  2. Result will have the shape of A.

Example (pseudocode):

let a = [3, 3, 3];
let b = [2, 2, 2];
let result = a.mul(b);
assert_eq!(result, [6, 6, 6]);
Source

pub fn div<T: AsRef<GTensor<DIMS>>>(&self, rhs: T) -> Self

Elementwise divide tensor A by tensor B. Returns a new tensor.

a.div(b) or a / b

Invariants

  1. A and B must have the same shape.
  2. Result will have the shape of A.

Example (pseudocode):

let a = [6, 6, 6];
let b = [2, 2, 2];
let result = a.div(b);
assert_eq!(result, [3, 3, 3]);
Source

pub fn scale<const RDIMS: usize, T: AsRef<GTensor<RDIMS>>>( &self, rhs: T, ) -> Self
where Dim<RDIMS>: DimValid, DimPair<1, RDIMS>: DimEq,

Scale tensor A by tensor B. This is basically just scalar multiplication. Returns a new tensor.

a.scale(b)

Invariants

  1. Tensor B must have shape [1]. (AKA 1d tensor with a single item.)
  2. Result will have the shape of A.

Example (pseudocode):

let a = [3, 3, 3];
let b = [2];
let result = a.scale(b);
assert_eq!(result, [6, 6, 6]);
Source

pub fn repeat<const RDIMS: usize, T: AsRef<GTensor<RDIMS>>>( &self, rhs: T, ) -> GTensor<RDIMS>
where Dim<RDIMS>: DimValid, DimPair<DIMS, 3>: DimLt, DimPair<RDIMS, 3>: DimLt,

Repeat tensor A based on the shape of tensor B. The content of B is not used. Returns a new tensor.

a.repeat(b)

Invariants

  1. Both A and B must be 1d or 2d tensors.
  2. Neither A or B can be transposed or permuted.
  3. The shape of B must be divisible by the shape of A. In other words, b_rows % a_rows and b_cols % a_cols must both be 0.
  4. Result will have the shape of B.

Example (pseudocode):

let a =
    [ [2, 3],
      [4, 5] ];
let b =
    [ [1, 1, 1, 1],
      [1, 1, 1, 1],
      [1, 1, 1, 1],
      [1, 1, 1, 1] ];
let expected =
    [ [2, 3, 2, 3],
      [4, 5, 4, 5],
      [2, 3, 2, 3],
      [4, 5, 4, 5] ];
let result = a.repeat(b);
assert_eq!(result, expected);
Source

pub fn conv_1d<const RDIMS: usize, const ODIMS: usize, T: AsRef<GTensor<RDIMS>>>( &self, rhs: T, s0: usize, p0: usize, d0: usize, ) -> Self
where Dim<RDIMS>: DimValid, Dim<ODIMS>: DimValid, DimPair<DIMS, 2>: DimGtE, DimPair<DIMS, 4>: DimLt, DimPair<RDIMS, 2>: DimGtE, DimPair<ODIMS, 2>: DimEq,

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn permute(&self, axes: [usize; 4]) -> Self

Create a view A of based on the specified order of dimensions. Returns a new tensor.

Note: Dimensions start from 0, so 0 is the 1st dimension, 3 is the 4th.

a.permute([4, 2, 1, 1])

Invariants

  1. The axes must be unique. [0, 0, 1, 2] would be invalid, for example.
  2. The axes must be a valid dimension. In other words, a number between 0 and 3 inclusive.

Example (pseudocode):

let a =
    [ [1, 1, 1],
      [2, 2, 3],
      [3, 3, 3] ];
let expected =
    [ [1, 2, 3],
      [1, 2, 3],
      [1, 2, 3] ];
let result = a.permute([1, 0, 2, 3]);
assert_eq!(result, expected);
Source

pub fn reshape_with<const RDIMS: usize, T: AsRef<GTensor<RDIMS>>>( &self, rhs: T, ) -> GTensor<RDIMS>
where Dim<RDIMS>: DimValid,

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn get_rows<const RDIMS: usize, const ODIMS: usize, T: AsRef<GTensor<RDIMS>>>( &self, rhs: T, ) -> GTensor<ODIMS>
where Dim<RDIMS>: DimValid, Dim<ODIMS>: DimValid, DimPair<DIMS, 2>: DimGtE, DimPair<RDIMS, 2>: DimLt, DimPair<ODIMS, 2>: DimEq,

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source§

impl<const DIMS: usize> GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source

pub fn map_unary( &self, fun: unsafe extern "C" fn(arg1: c_int, arg2: *mut f32, arg3: *const f32), ) -> Self

Elementwise unary map operation on tensor A. Returns a new tensor.

Note: This function is rather unfriendly to use directly. See the map_unop! macro which will help you create the required unsafe extern "C" function.

a.map_unary(unary_fun_ptr)

Invariants

  1. The tensor must be of type GType::F32.
  2. The result will be the same shape and type as A.

Example (pseudocode):

use std::ffi::c_int;
unsafe extern "C" fn unary_map_fn(n: c_int, dst: *mut f32, src: *const f32) {
    let dst = ::std::slice::from_raw_parts_mut(dst, n as usize);
    let src = ::std::slice::from_raw_parts(src, n as usize);
    dst.iter_mut()
        .zip(src.iter().copied())
        .for_each(|(dst, src0)| *dst = src + 10);
}

let a = [1, 2, 3, 4];
let result = a.map_unary(unary_map_fn);
assert_eq!(result, [11, 12, 13, 14]);
Source

pub fn map_binary<T: AsRef<GTensor<DIMS>>>( &self, rhs: T, fun: unsafe extern "C" fn(arg1: c_int, arg2: *mut f32, arg3: *const f32, arg4: *const f32), ) -> Self

Elementwise binary map operation on tensors A and B. Returns a new tensor.

Note: This function is rather unfriendly to use directly. See the map_binop! macro which will help you create the required unsafe extern "C" function.

a.map_binary(b, binary_fun_ptr)

Invariants

  1. The tensor must be of type GType::F32.
  2. A and B must be the same shape.
  3. The result will be the same shape and type as A.

Example (pseudocode):

use std::ffi::c_int;
unsafe extern "C" fn binary_map_fn(
    n: c_int,
    dst: *mut f32,
    src0: *const f32
    src1: *const f32
) {
    let dst = ::std::slice::from_raw_parts_mut(dst, n as usize);
    let src0 = ::std::slice::from_raw_parts(src, n as usize);
    let src1 = ::std::slice::from_raw_parts(src, n as usize);
    dst.iter_mut()
        .zip(src0.iter().copied())
        .zip(src1.iter().copied())
        .for_each(|((dst, src0), src1)| *dst = src0 + src1);
}

let a = [1, 2, 3, 4];
let a = [10, 10, 10, 10];
let result = a.map_binary(b, binary_map_fn);
assert_eq!(result, [11, 12, 13, 14]);
Source§

impl<const DIMS: usize> GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source

pub const DIMS: usize = DIMS

Alternate method to access a tensor’s dimensions without needing an actual GTensor value to work with.

Source

pub fn dims(&self) -> usize

Return the number of dimensions for this tensor.

Source

pub fn len(&self) -> usize

Returns the tensor data length in bytes.

Source

pub fn is_empty(&self) -> bool

true if the tensor is empty.

Source

pub fn elements(&self) -> usize

Returns the number of elements in this tensor.

Source

pub fn element_size(&self) -> usize

Returns the number of bytes each element uses.

Note: May not be accurate for quantized types.

Source

pub fn shape(&self) -> [usize; DIMS]

Return the shape of this tensor as an array.

Note: The length of the shape array will be equal to the tensor’s dimensions.

Source

pub fn ggml_op(&self) -> ggml_op

Returns the GGML operation associated with this tensor if available.

Source

pub fn element_type(&self) -> GType

Returns the element type.

Source

pub fn metadata(&self) -> GTensorMetadata<DIMS>

Returns a copy of the metadata associated with this tensor.

Source

pub fn get_ne(&self) -> [u32; 4]

Returns GGML’s conception of this tensor’s shape.

Note: This is a low level function. Be aware that GGML shapes have the first two dimensions swapped.

Source

pub fn get_nb(&self) -> [u32; 4]

Returns GGML’s conception of this tensor’s strides in bytes.

Note: This is a low level function. Be aware that GGML shapes have the first two dimensions swapped. This also applies to the order of strides.

Note 2: Also be aware that the strides are based on bytes, and not the number of elements.

Source

pub fn fill_zero(&mut self)

Immediately fills the tensor’s data with zeros.

Source

pub fn fill_i32(&mut self, val: i32)

Immediately fills the tensor’s data with the specified i32 value.

Invariants

  1. The tensor’s type must not be quantized.
Source

pub fn fill_f32(&mut self, val: f32)

Immediately fills the tensor’s data with the specified f32 value.

Invariants

  1. The tensor’s type must not be quantized.
Source

pub fn get_f32_1d(&self, index: usize) -> Result<f32>

Immediately returns the value of an element at the specified index as a f32.

Invariants

  1. The tensor’s type must not be quantized.
  2. The index must be valid.
Source

pub fn get_i32_1d(&self, index: usize) -> Result<i32>

Immediately returns the value of an element at the specified index as an i32.

Invariants

  1. The tensor’s type must not be quantized.
  2. The index must be valid.
Source

pub fn set_f32_1d(&mut self, index: usize, val: f32)

Immediately set the value of an element at the specified index to the specified f32 value.

Invariants

  1. The tensor’s type must not be quantized.
  2. The index must be valid.
Source

pub fn set_i32_1d(&mut self, index: usize, val: i32)

Immediately set the value of an element at the specified index to the specified i32 value.

Invariants

  1. The tensor’s type must not be quantized.
  2. The index must be valid.
Source§

impl<const DIMS: usize> GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source

pub unsafe fn with_data_mut<F, O>(&mut self, fun: F) -> Result<O>
where F: FnOnce(&mut [u8]) -> O,

Low level function that allows mutably accessing a tensor’s data as a slice of u8.

§Safety

Since this is working with the raw bytes, you need to be careful not to reinterpret as the wrong type or set the data to something that would contain an invalid value for the type.

Source

pub unsafe fn with_data<F, O>(&self, fun: F) -> Result<O>
where F: FnOnce(&[u8]) -> O,

Low level function that allows accessing a tensor’s data as a slice of u8.

§Safety

Since this is working with the raw bytes, you need to be careful not to reinterpret as the wrong type.

Source

pub unsafe fn populate_raw<S: AsRef<[u8]>>(&mut self, data: S)

§Safety

Fills a tensor with raw data. It’s your responsibility to make sure the format is correct.

Source§

impl<const DIMS: usize> GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source

pub fn copy_from<T: AsRef<GTensor<DIMS>>>(&mut self, rhs: T)

Copies data from the specified tensor into this tensor when the graph runs.

Note: This immediately overwrites self with the copy.

Source

pub fn populate_f32<S: AsRef<[f32]>>(&mut self, data: S)

Immediately copy the specified f32 values into this tensor.

Invariants

  1. The tensor must be of type GType::F32.
  2. The length of the incoming data must match the size of the tensor.
Source

pub fn copy_to_slice_f32<S: AsMut<[f32]>>(&self, dest: S) -> Result<()>

Immediately copy the data from this tensor to the specified destination.

Invariants

  1. The tensor must be of type GType::F32.
  2. The length of the destination must match the size of the tensor.
  3. The destination must be elements of f32.
Source§

impl<const DIMS: usize> GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source

pub fn sqr(&self) -> Self

Elementwise square of tensor A. This is the same as a map where each element is multiplied by itself. Returns a new tensor.

a.sqr()

Invariants

  1. Result will have the shape of A.

Example (pseudocode):

let a = [2, 2, 2];
let result = a.sqr();
assert_eq!(result, [4, 4, 4]);
Source

pub fn sqrt(&self) -> Self

Elementwise square root of tensor A. Returns a new tensor.

a.sqrt()

Invariants

  1. Result will have the shape of A.

Example (pseudocode):

let a = [9, 9, 9];
let result = a.sqrt();
assert_eq!(result, [3, 3, 3]);
Source

pub fn abs(&self) -> Self

Elementwise abs of tensor A. Returns a new tensor.

a.abs()

Invariants

  1. Result will have the shape of A.

Example (pseudocode):

let a = [-1, -2, -3];
let result = a.abs();
assert_eq!(result, [1, 2, 3]);
Source

pub fn sgn(&self) -> Self

Elementwise sign operation on tensor A. Returns a new tensor.

a.sgn()

Invariants

  1. If an element is 0 then the result will be 0.
  2. If an element is over 0 then the result will be 1.
  3. If an element is less than 0 then the result will be -1.
  4. Result will have the shape of A.

Example (pseudocode):

let a = [-5, 0, 6];
let result = a.sgn();
assert_eq!(result, [-1, 0, 1]);
Source

pub fn neg(&self) -> Self

Elementwise negation operation on tensor A. In other words, it just flips the sign. Returns a new tensor.

a.neg()

Invariants

  1. Result will have the shape of A.

Example (pseudocode):

let a = [1, -1, -6, 7];
let result = a.sgn();
assert_eq!(result, [-1, 1, 6, -7]);
Source

pub fn step(&self) -> Self

Elementwise step operation on tensor A. Returns a new tensor.

a.step()

See https://en.wikipedia.org/wiki/Activation_function

Invariants

  1. If an element is over 0 then the result will be 1.
  2. If an element is less or equal to 0 then the result will be 0.
  3. Result will have the shape of A.

Example (pseudocode):

let a = [1, -1, -6, 7];
let result = a.step();
assert_eq!(result, [1, 0, 0, 1]);
Source

pub fn relu(&self) -> Self

Perform ReLU operation on tensor A. Returns a new tensor.

a.relu()

See https://en.wikipedia.org/wiki/Activation_function

Invariants

  1. If an element is over 0 then the element passes through unchanged.
  2. If an element is less or equal to 0 then the result will be 0.
  3. Result will have the shape of A.

Example (pseudocode):

let a = [1, -1, -6, 7];
let result = a.relu();
assert_eq!(result, [1, 0, 0, 7]);
Source

pub fn gelu(&self) -> Self

Perform GELU (AKA “Gaussian Error Linear Unit”) operation on tensor A. Returns a new tensor.

a.gelu()

See https://en.wikipedia.org/wiki/Activation_function

Source

pub fn silu(&self) -> Self

Perform SiLU (AKA “Sigmoid Linear Unit”) operation on tensor A. Returns a new tensor.

a.silu()

See https://en.wikipedia.org/wiki/Activation_function

Source

pub fn cont(&self) -> Self

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn transpose(&self) -> Self

Create a view A with the first and second dimensions flipped. Returns a new tensor.

Note: This is the same as a.permute([1, 0, 2, 3]).

a.transpose()

Example (pseudocode):

let a =
    [ [1, 1, 1],
      [2, 2, 3],
      [3, 3, 3] ];
let expected =
    [ [1, 2, 3],
      [1, 2, 3],
      [1, 2, 3] ];
let result = a.transpose();
assert_eq!(result, expected);
Source

pub fn soft_max(&self) -> Self

Apply the softmax (AKA softargmax or “normalized exponential function”) to A. Returns a new tensor.

a.soft_max()

This one is a bit too complicated to explain here. See https://en.wikipedia.org/wiki/Softmax_function

Invariants

  1. Result will have the shape and type of A.
Source

pub fn norm(&self, eps: f32) -> Self

Perform LayerNorm operation on tensor A. Returns a new tensor.

a.norm()

See this helpful explanation for more information and comparison with the GTensor::rms_norm function.

Source

pub fn rms_norm(&self, eps: f32) -> Self

Perform RMSNorm operation on tensor A. Returns a new tensor.

a.rms_norm()

See this helpful explanation for more information and comparison with the GTensor::norm function.

Source

pub fn mean<const ODIMS: usize>(&self) -> GTensor<ODIMS>
where Dim<ODIMS>: DimValid, DimPair<ODIMS, 2>: DimLt,

Elementwise mean of tensor A. Returns a new tensor.

a.mean()

Invariants

  1. Result will be a 1 dimensional tensor with one item.
  2. The result tensor will have type GType::F32.

Example (pseudocode):

let a = [1, 2, 3, 4];
let result = a.mean();
assert_eq!(result, [2.5]);
Source

pub fn sum<const ODIMS: usize>(&self) -> GTensor<ODIMS>
where Dim<ODIMS>: DimValid, DimPair<ODIMS, 2>: DimLt,

Elementwise sum of tensor A. Returns a new tensor.

a.sum()

Invariants

  1. Result will be a 1 dimensional tensor with one item.
  2. The result tensor will the same type as A.

Example (pseudocode):

let a = [1, 2, 3, 4];
let result = a.sum();
assert_eq!(result, [10]);
Source

pub fn reshape<const ODIMS: usize>(&self, ne: [usize; ODIMS]) -> GTensor<ODIMS>
where Dim<ODIMS>: DimValid, DimPair<ODIMS, 2>: DimGtE, DimPair<ODIMS, 4>: DimLt,

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn view<const ODIMS: usize>( &self, ne: [i64; ODIMS], offset: [usize; ODIMS], ) -> GTensor<ODIMS>
where Dim<ODIMS>: DimValid, DimPair<ODIMS, 3>: DimLt,

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn diag_mask_inf(self, val: usize) -> Self

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn rope( self, n_past: usize, n_dims: usize, mode: usize, n_ctx: usize, ) -> Self

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!
Source

pub fn rope_custom( self, n_past: usize, n_dims: usize, mode: usize, n_ctx: usize, freq_base: f32, freq_scale: f32, ) -> Self

§!!!! FIXME !!!!
§!!!! FIXME !!!!
§!!!! FIXME !!!!

Trait Implementations§

Source§

impl<'a, const DIMS: usize, T: AsRef<GTensor<DIMS>>> Add<T> for &'a GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<const DIMS: usize, T: AsRef<GTensor<DIMS>>> Add<T> for GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<const DIMS: usize> AsRef<GTensor<DIMS>> for GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

fn as_ref(&self) -> &GTensor<DIMS>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a, 'b> BitXor<&'b GTensor<1>> for &'a GTensor<2>
where GTensor<2>: GMulMat<2, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, 'b> BitXor<&'b GTensor<1>> for &'a GTensor<3>
where GTensor<3>: GMulMat<3, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<&'a GTensor<1>> for GTensor<2>
where GTensor<2>: GMulMat<2, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<&'a GTensor<1>> for GTensor<3>
where GTensor<3>: GMulMat<3, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, 'b> BitXor<&'b GTensor<2>> for &'a GTensor<1>
where GTensor<1>: GMulMat<1, 2>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, 'b> BitXor<&'b GTensor<2>> for &'a GTensor<3>
where GTensor<3>: GMulMat<3, 2>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<&'a GTensor<2>> for GTensor<1>
where GTensor<1>: GMulMat<1, 2>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<&'a GTensor<2>> for GTensor<3>
where GTensor<3>: GMulMat<3, 2>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, 'b> BitXor<&'b GTensor<3>> for &'a GTensor<1>
where GTensor<1>: GMulMat<1, 3>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, 'b> BitXor<&'b GTensor<3>> for &'a GTensor<2>
where GTensor<2>: GMulMat<2, 3>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'b GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<&'a GTensor<3>> for GTensor<1>
where GTensor<1>: GMulMat<1, 3>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<&'a GTensor<3>> for GTensor<2>
where GTensor<2>: GMulMat<2, 3>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &'a GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<GTensor<1>> for &'a GTensor<2>
where GTensor<2>: GMulMat<2, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<GTensor<1>> for &'a GTensor<3>
where GTensor<3>: GMulMat<3, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<GTensor<1>> for GTensor<2>
where GTensor<2>: GMulMat<2, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<GTensor<1>> for GTensor<3>
where GTensor<3>: GMulMat<3, 1>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<1>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<GTensor<2>> for &'a GTensor<1>
where GTensor<1>: GMulMat<1, 2>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<GTensor<2>> for &'a GTensor<3>
where GTensor<3>: GMulMat<3, 2>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<GTensor<2>> for GTensor<1>
where GTensor<1>: GMulMat<1, 2>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<GTensor<2>> for GTensor<3>
where GTensor<3>: GMulMat<3, 2>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<2>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<GTensor<3>> for &'a GTensor<1>
where GTensor<1>: GMulMat<1, 3>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a> BitXor<GTensor<3>> for &'a GTensor<2>
where GTensor<2>: GMulMat<2, 3>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<GTensor<3>> for GTensor<1>
where GTensor<1>: GMulMat<1, 3>,

Source§

type Output = GTensor<1>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl BitXor<GTensor<3>> for GTensor<2>
where GTensor<2>: GMulMat<2, 3>,

Source§

type Output = GTensor<2>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: GTensor<3>) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<'a, const DIMS: usize, T: AsRef<GTensor<DIMS>>> BitXor<T> for &'a GTensor<DIMS>
where Dim<DIMS>: DimValid, GTensor<DIMS>: GMulMat<DIMS, DIMS>,

Source§

type Output = <GTensor<DIMS> as GMulMat<DIMS, DIMS>>::Output

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: T) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const DIMS: usize, T: AsRef<GTensor<DIMS>>> BitXor<T> for GTensor<DIMS>
where Dim<DIMS>: DimValid, Self: GMulMat<DIMS, DIMS>,

Source§

type Output = <GTensor<DIMS> as GMulMat<DIMS, DIMS>>::Output

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: T) -> Self::Output

Performs the ^ operation. Read more
Source§

impl<const DIMS: usize> Clone for GTensor<DIMS>

Source§

fn clone(&self) -> GTensor<DIMS>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, const DIMS: usize, T: AsRef<GTensor<DIMS>>> Div<T> for &'a GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<const DIMS: usize, T: AsRef<GTensor<DIMS>>> Div<T> for GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Self::Output

Performs the / operation. Read more
Source§

impl GMulMat<1, 2> for GTensor<1>

Source§

type Output = GTensor<1>

Source§

fn mul_mat<T: AsRef<GTensor<2>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl GMulMat<1, 3> for GTensor<1>

Source§

type Output = GTensor<1>

Source§

fn mul_mat<T: AsRef<GTensor<3>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl GMulMat<2, 1> for GTensor<2>

Source§

type Output = GTensor<1>

Source§

fn mul_mat<T: AsRef<GTensor<1>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl GMulMat<2, 3> for GTensor<2>

Source§

type Output = GTensor<2>

Source§

fn mul_mat<T: AsRef<GTensor<3>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl GMulMat<3, 1> for GTensor<3>

Source§

type Output = GTensor<1>

Source§

fn mul_mat<T: AsRef<GTensor<1>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl GMulMat<3, 2> for GTensor<3>

Source§

type Output = GTensor<2>

Source§

fn mul_mat<T: AsRef<GTensor<2>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl<const DIMS: usize> GMulMat<DIMS, DIMS> for GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

Source§

fn mul_mat<T: AsRef<GTensor<DIMS>>>(&self, rhs: T) -> Self::Output

Matrix multiplication of tensor A with tensor B. Returns a new tensor. Read more
Source§

impl<'a, const DIMS: usize, T: AsRef<GTensor<DIMS>>> Mul<T> for &'a GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<const DIMS: usize, T: AsRef<GTensor<DIMS>>> Mul<T> for GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<const DIMS: usize> PartialEq for GTensor<DIMS>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, const DIMS: usize, T: AsRef<GTensor<DIMS>>> Sub<T> for &'a GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<const DIMS: usize, T: AsRef<GTensor<DIMS>>> Sub<T> for GTensor<DIMS>
where Dim<DIMS>: DimValid,

Source§

type Output = GTensor<DIMS>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<const DIMS: usize> Freeze for GTensor<DIMS>

§

impl<const DIMS: usize> RefUnwindSafe for GTensor<DIMS>

§

impl<const DIMS: usize> !Send for GTensor<DIMS>

§

impl<const DIMS: usize> !Sync for GTensor<DIMS>

§

impl<const DIMS: usize> Unpin for GTensor<DIMS>

§

impl<const DIMS: usize> UnwindSafe for GTensor<DIMS>

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> 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.