Crates.io | caffe2-math |
lib.rs | caffe2-math |
version | 0.1.5-alpha.0 |
source | src |
created_at | 2023-03-01 10:10:04.950392 |
updated_at | 2023-03-25 09:51:53.369409 |
description | xxx |
homepage | |
repository | https://github.com/kleb6/caffe2-rs |
max_upload_size | |
id | 797915 |
size | 364,829 |
This crate provides a collection of mathematical utilities and functions for the Caffe2 Operator Library, written in Rust. The crate is in the process of being translated from C++ to Rust, and some function bodies may be in the process of translation.
This crate features a variety of functions and structures that handle mathematical operations and data manipulation. The naming convention used is snake_case for functions, and CamelCase for structs and enums.
Here are some of the mathematical ideas and equations that can be found in this crate:
both_ends_moments
, colwise_moments
, and
rowwise_moments
: These functions compute the
moments of a given tensor along different axes
(both ends, column-wise, and row-wise). Moments
are measures of the distribution shape, where
the first moment is the mean (µ), and the
second moment is the variance (σ²).
µ = Σ(x) / N σ² = Σ(x - µ)² / N
reduceL1
and reduceL2
: These functions
calculate the L1 and L2 norms of a given
tensor, respectively. The L1 norm is the sum of
the absolute values of the elements, and the L2
norm is the square root of the sum of the
squared elements.
L1 = Σ|x| L2 = √(Σx²)
reduce_max
, reduce_min
, reduce_mean
, and
reduce_sum
: These functions compute the
maximum, minimum, mean, and sum of a given
tensor, respectively.
caffe2_specialized_axpy
: This function
performs the axpy operation, which is a linear
combination of two vectors with the form y = a * x + y
.
gemm
, gemv
, and related functions: These
functions perform General Matrix-Matrix
Multiplication (GEMM) and General Matrix-Vector
Multiplication (GEMV) operations, which are
common linear algebra procedures.
cos
, sin
, tan
, acos
, asin
, atan
,
cosh
, sinh
, and tanh
: These functions
perform trigonometric and hyperbolic operations
on the given input.
exp
, log
, and log1p
: These functions
calculate the exponential, natural logarithm,
and natural logarithm of 1 plus the input,
respectively.
powx
, sqrt
, and cbrt
: These functions
compute the power, square root, and cube root
of the input, respectively.
broadcast
: This function enables
broadcasting, which is the process of applying
an operation element-wise to two tensors with
different shapes, following broadcasting rules.
The crate also contains various tests, such as
BroadcastTest
, GemmBatchedTest
, and
RandFixedSumTest
, to ensure the correctness and
performance of the provided functions and
utilities.
For a complete understanding of the crate and its capabilities, please refer to the source code and documentation.
2> thanks! could you keep on describing more of the tokens in this crate? the current level of detail and groupings are great!
Certainly! Here's a description of more tokens in the crate:
bitwise_and
, bitwise_or
, bitwise_xor
:
These functions perform bitwise operations
(AND, OR, XOR) on the given input tensors.
abs
, neg
, sign
, floor
, ceil
,
round
, and trunc
: These functions perform
element-wise transformations on the given
input tensor, such as absolute value,
negation, sign, and rounding operations.
add
, sub
, mul
, and div
: These
functions perform element-wise arithmetic
operations (addition, subtraction,
multiplication, and division) on the input
tensors.
max
and min
: These functions compute the
element-wise maximum and minimum of the input
tensors, respectively.
caffe2_specialized_scale
: This function
scales an input tensor by a scalar value,
i.e., performs element-wise multiplication
with a scalar.
caffe2_specialized_set
: This function sets
the elements of a given tensor to a specified
value.
erf
and cdf_norm
: These functions compute
the error function and the cumulative
distribution function (CDF) of the standard
normal distribution for the input,
respectively.
delegate_simple_binary_function_by_eigen_function
,
delegate_simple_binary_function_by_eigen_operator
,
and
delegate_simple_binary_function_by_std_function
:
These functions delegate the implementation of
simple binary functions to Eigen, a C++
template library for linear algebra, or the
standard library.
delegate_simple_unary_function
: This
function delegates the implementation of
simple unary functions to an appropriate
implementation.
caffe2_specialized_broadcast
: This function
implements the broadcasting operation for
a binary operation on two input tensors with
different shapes.
im_2col
, im_2col_nd
, col_2im
, and
col_2im_nd
: These functions perform
image-to-column and column-to-image
transformations, which are used in the
implementation of convolutional layers in
neural networks. They efficiently reorganize
the data for matrix multiplication.
gemm_batched
and gemm_strided_batched
:
These functions perform batched General
Matrix-Matrix Multiplication (GEMM)
operations, where multiple matrix
multiplications are performed in parallel.
rand_uniform
, rand_gaussian
,
rand_fixed_sum
, and rand_synthetic_data
:
These functions generate random data following
various distributions (uniform, Gaussian,
fixed sum, and synthetic data) for the given
input tensors.
transpose
, transpose2D
, and transposeND
:
These functions perform matrix transposition
operations for 2D and N-dimensional tensors.
caffe2_specialized_nchw2nhwc
and
caffe2_specialized_nhwc2nchw
: These
functions convert between NCHW (batch,
channel, height, width) and NHWC (batch,
height, width, channel) data formats, which
are commonly used in convolutional neural
networks.
affine_channel
and
caffe2_specialized_affine_channel
: These
functions implement the affine channel
operation, which is used to apply scale and
bias transformations to input tensors in
neural networks.
bias_chwf32cpu_context
: This function
applies a bias tensor to an input tensor,
commonly used in neural networks after
a convolution operation.
colwise_max
and rowwise_max
: These
functions compute the column-wise and row-wise
maximum values of the input tensor,
respectively.