caffe2-math

Crates.iocaffe2-math
lib.rscaffe2-math
version0.1.5-alpha.0
sourcesrc
created_at2023-03-01 10:10:04.950392
updated_at2023-03-25 09:51:53.369409
descriptionxxx
homepage
repositoryhttps://github.com/kleb6/caffe2-rs
max_upload_size
id797915
size364,829
(klebs6)

documentation

https://docs.rs/caffe2-math

README

Mathematical Utilities for Caffe2 Operator Library in Rust

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:

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

  2. 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²)

  3. reduce_max, reduce_min, reduce_mean, and reduce_sum: These functions compute the maximum, minimum, mean, and sum of a given tensor, respectively.

  4. caffe2_specialized_axpy: This function performs the axpy operation, which is a linear combination of two vectors with the form y = a * x + y.

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

  6. cos, sin, tan, acos, asin, atan, cosh, sinh, and tanh: These functions perform trigonometric and hyperbolic operations on the given input.

  7. exp, log, and log1p: These functions calculate the exponential, natural logarithm, and natural logarithm of 1 plus the input, respectively.

  8. powx, sqrt, and cbrt: These functions compute the power, square root, and cube root of the input, respectively.

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

  1. bitwise_and, bitwise_or, bitwise_xor: These functions perform bitwise operations (AND, OR, XOR) on the given input tensors.

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

  3. add, sub, mul, and div: These functions perform element-wise arithmetic operations (addition, subtraction, multiplication, and division) on the input tensors.

  4. max and min: These functions compute the element-wise maximum and minimum of the input tensors, respectively.

  5. caffe2_specialized_scale: This function scales an input tensor by a scalar value, i.e., performs element-wise multiplication with a scalar.

  6. caffe2_specialized_set: This function sets the elements of a given tensor to a specified value.

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

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

  9. delegate_simple_unary_function: This function delegates the implementation of simple unary functions to an appropriate implementation.

  10. caffe2_specialized_broadcast: This function implements the broadcasting operation for a binary operation on two input tensors with different shapes.

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

  12. gemm_batched and gemm_strided_batched: These functions perform batched General Matrix-Matrix Multiplication (GEMM) operations, where multiple matrix multiplications are performed in parallel.

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

  14. transpose, transpose2D, and transposeND: These functions perform matrix transposition operations for 2D and N-dimensional tensors.

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

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

  17. bias_chwf32cpu_context: This function applies a bias tensor to an input tensor, commonly used in neural networks after a convolution operation.

  18. colwise_max and rowwise_max: These functions compute the column-wise and row-wise maximum values of the input tensor, respectively.

Commit count: 105

cargo fmt